Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix blocking issue when cell contains ipywidget #311

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading