Skip to content

Commit

Permalink
fix blocking issue when cell contains ipywidget
Browse files Browse the repository at this point in the history
  • Loading branch information
huajie.liu committed May 13, 2024
1 parent a72fb94 commit e2849e3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions nbclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,15 @@ async def _async_poll_for_reply(
) -> dict[str, t.Any]:
msg: dict[str, t.Any]
assert self.kc is not None
new_timeout: float | None = None
if timeout is not None:
deadline = monotonic() + timeout
new_timeout = float(timeout)
else:
# if we call shell_channel.get_msg with None timeout value, sometimes will
# block current execution forever so need pass a timeout value, so we
# need give a default value and reset the value when timeout value exhausted
deadline = monotonic() + 5
new_timeout = float(5)
error_on_timeout_execute_reply = None
while True:
try:
Expand Down Expand Up @@ -800,7 +805,10 @@ async def _async_poll_for_reply(
new_timeout = max(0, deadline - monotonic())
except Empty:
# received no message, check if kernel is still alive
assert timeout is not None
if timeout is None:
deadline = monotonic() + 5
new_timeout = float(5)
continue
task_poll_kernel_alive.cancel()
await self._async_check_alive()
error_on_timeout_execute_reply = await self._async_handle_timeout(timeout, cell)
Expand Down

0 comments on commit e2849e3

Please sign in to comment.