Skip to content

Commit 89fee5e

Browse files
committed
Fix some broken logic
1 parent 28e62b9 commit 89fee5e

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

jupyter_client/ioloop/restarter.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66
# Copyright (c) Jupyter Development Team.
77
# Distributed under the terms of the Modified BSD License.
8-
import inspect
8+
import asyncio
99
import time
1010
import warnings
1111

@@ -34,11 +34,8 @@ def _loop_default(self):
3434
def start(self):
3535
"""Start the polling of the kernel."""
3636
if self._pcallback is None:
37-
if inspect.isawaitable(self.poll):
38-
39-
def cb():
40-
run_sync(self.poll)
41-
37+
if asyncio.iscoroutinefunction(self.poll):
38+
cb = run_sync(self.poll)
4239
else:
4340
cb = self.poll
4441
self._pcallback = ioloop.PeriodicCallback(
@@ -97,8 +94,8 @@ async def poll(self):
9794
stable_start_time = self.kernel_manager.provisioner.get_stable_start_time(
9895
recommended=stable_start_time
9996
)
100-
if self._initial_startup and self._last_dead - now >= stable_start_time:
97+
if self._initial_startup and now - self._last_dead >= stable_start_time:
10198
self._initial_startup = False
102-
if self._restarting and self._last_dead - now >= stable_start_time:
99+
if self._restarting and now - self._last_dead >= stable_start_time:
103100
self.log.debug("AsyncIOLoopKernelRestarter: restart apparently succeeded")
104101
self._restarting = False

jupyter_client/restarter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ def poll(self):
155155
stable_start_time = self.kernel_manager.provisioner.get_stable_start_time(
156156
recommended=stable_start_time
157157
)
158-
if self._initial_startup and self._last_dead - now >= stable_start_time:
158+
if self._initial_startup and now - self._last_dead >= stable_start_time:
159159
self._initial_startup = False
160-
if self._restarting and self._last_dead - now >= stable_start_time:
160+
if self._restarting and now - self._last_dead >= stable_start_time:
161161
self.log.debug("KernelRestarter: restart apparently succeeded")
162162
self._restarting = False

0 commit comments

Comments
 (0)