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

Use tornado 6.2's PeriodicCallback in restarter #822

Merged
merged 5 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .github/workflows/downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ jobs:
git clone https://github.com/jupyter/jupyter_kernel_test.git
cd jupyter_kernel_test
conda env update --name jupyter_kernel_test --file environment.yml
conda install -c conda-forge xeus-cling
pip install -e ".[test]"
python -m unittest -v

Expand Down
15 changes: 6 additions & 9 deletions jupyter_client/ioloop/restarter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
"""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import asyncio
import time
import warnings

from traitlets import Instance
from zmq.eventloop import ioloop

from jupyter_client.restarter import KernelRestarter
from jupyter_client.utils import run_sync


class IOLoopKernelRestarter(KernelRestarter):
Expand All @@ -27,19 +24,19 @@ def _loop_default(self):
DeprecationWarning,
stacklevel=4,
)
from zmq.eventloop import ioloop

return ioloop.IOLoop.current()

_pcallback = None

def start(self):
"""Start the polling of the kernel."""
if self._pcallback is None:
if asyncio.iscoroutinefunction(self.poll):
cb = run_sync(self.poll)
else:
cb = self.poll
self._pcallback = ioloop.PeriodicCallback(
cb,
from tornado.ioloop import PeriodicCallback

self._pcallback = PeriodicCallback(
self.poll,
1000 * self.time_to_dead,
)
self._pcallback.start()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies = [
"nest-asyncio>=1.5.4",
"python-dateutil>=2.8.2",
"pyzmq>=23.0",
"tornado>=6.0",
"tornado>=6.2",
"traitlets",
]

Expand Down