Skip to content

Commit e2849e3

Browse files
author
huajie.liu
committed
fix blocking issue when cell contains ipywidget
1 parent a72fb94 commit e2849e3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

nbclient/client.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,10 +768,15 @@ async def _async_poll_for_reply(
768768
) -> dict[str, t.Any]:
769769
msg: dict[str, t.Any]
770770
assert self.kc is not None
771-
new_timeout: float | None = None
772771
if timeout is not None:
773772
deadline = monotonic() + timeout
774773
new_timeout = float(timeout)
774+
else:
775+
# if we call shell_channel.get_msg with None timeout value, sometimes will
776+
# block current execution forever so need pass a timeout value, so we
777+
# need give a default value and reset the value when timeout value exhausted
778+
deadline = monotonic() + 5
779+
new_timeout = float(5)
775780
error_on_timeout_execute_reply = None
776781
while True:
777782
try:
@@ -800,7 +805,10 @@ async def _async_poll_for_reply(
800805
new_timeout = max(0, deadline - monotonic())
801806
except Empty:
802807
# received no message, check if kernel is still alive
803-
assert timeout is not None
808+
if timeout is None:
809+
deadline = monotonic() + 5
810+
new_timeout = float(5)
811+
continue
804812
task_poll_kernel_alive.cancel()
805813
await self._async_check_alive()
806814
error_on_timeout_execute_reply = await self._async_handle_timeout(timeout, cell)

0 commit comments

Comments
 (0)