From 3790fe51663948aaa7f1ffa51bddc1fa1185e40b Mon Sep 17 00:00:00 2001 From: DInne Bosman Date: Sun, 17 Feb 2019 22:34:12 +0100 Subject: [PATCH 1/3] Solves hanging indefinitely when kernel dies --- nbconvert/preprocessors/execute.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/nbconvert/preprocessors/execute.py b/nbconvert/preprocessors/execute.py index ff051603c..34d9adf74 100644 --- a/nbconvert/preprocessors/execute.py +++ b/nbconvert/preprocessors/execute.py @@ -414,6 +414,24 @@ def _wait_for_reply(self, msg_id, cell=None): if not timeout or timeout < 0: timeout = None msg = self.kc.shell_channel.get_msg(timeout=timeout) + + if timeout is not None: + # timeout specified + msg = self.kc.shell_channel.get_msg(timeout=timeout) + else: + #no timeout specified, if kernel dies still handle this correctly + while True: + try: + #check every few seconds if kernel is still alive + msg = self.kc.shell_channel.get_msg(timeout=5) + except Empty: + #received no message, check if kernel is still alive + if not self.kc.is_alive(): + raise RuntimeError("Kernel died") + #kernel still alive, wait for a message + continue + #message received + break except Empty: self.log.error( "Timeout waiting for execute reply (%is)." % self.timeout) From 7c9d576a013731d3ebb51984387d315d372973ba Mon Sep 17 00:00:00 2001 From: DInne Bosman Date: Sun, 17 Feb 2019 22:47:44 +0100 Subject: [PATCH 2/3] commit typo --- nbconvert/preprocessors/execute.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nbconvert/preprocessors/execute.py b/nbconvert/preprocessors/execute.py index 34d9adf74..49dd24393 100644 --- a/nbconvert/preprocessors/execute.py +++ b/nbconvert/preprocessors/execute.py @@ -413,7 +413,6 @@ def _wait_for_reply(self, msg_id, cell=None): if not timeout or timeout < 0: timeout = None - msg = self.kc.shell_channel.get_msg(timeout=timeout) if timeout is not None: # timeout specified From caeab805caa06d67287c4ed91d1e5bf722a465a0 Mon Sep 17 00:00:00 2001 From: DInne Bosman Date: Tue, 19 Feb 2019 10:03:38 +0100 Subject: [PATCH 3/3] Trigger travis rebuild --- nbconvert/preprocessors/execute.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nbconvert/preprocessors/execute.py b/nbconvert/preprocessors/execute.py index 49dd24393..0f7e7b16c 100644 --- a/nbconvert/preprocessors/execute.py +++ b/nbconvert/preprocessors/execute.py @@ -427,6 +427,7 @@ def _wait_for_reply(self, msg_id, cell=None): #received no message, check if kernel is still alive if not self.kc.is_alive(): raise RuntimeError("Kernel died") + #kernel still alive, wait for a message continue #message received