Skip to content

Commit 6889cea

Browse files
committed
Prevent async restarter from re-entering
1 parent 6c803a7 commit 6889cea

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

jupyter_client/ioloop/restarter.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
"""
66
# Copyright (c) Jupyter Development Team.
77
# Distributed under the terms of the Modified BSD License.
8+
import inspect
89
import warnings
910

1011
from traitlets import Instance
1112
from zmq.eventloop import ioloop
1213

1314
from jupyter_client.restarter import KernelRestarter
15+
from jupyter_client.utils import run_sync
1416

1517

1618
class IOLoopKernelRestarter(KernelRestarter):
@@ -31,8 +33,12 @@ def _loop_default(self):
3133
def start(self):
3234
"""Start the polling of the kernel."""
3335
if self._pcallback is None:
36+
if inspect.isawaitable(self.poll):
37+
cb = lambda: run_sync(self.poll)
38+
else:
39+
cb = self.poll
3440
self._pcallback = ioloop.PeriodicCallback(
35-
self.poll,
41+
cb,
3642
1000 * self.time_to_dead,
3743
)
3844
self._pcallback.start()

0 commit comments

Comments
 (0)