diff --git a/jupyter_client/ioloop/restarter.py b/jupyter_client/ioloop/restarter.py index e36f3a33d..e386add8b 100644 --- a/jupyter_client/ioloop/restarter.py +++ b/jupyter_client/ioloop/restarter.py @@ -24,7 +24,7 @@ def _loop_default(self): DeprecationWarning, stacklevel=4, ) - from zmq.eventloop import ioloop + from tornado import ioloop return ioloop.IOLoop.current() diff --git a/jupyter_client/session.py b/jupyter_client/session.py index d253c1946..07b199d0e 100644 --- a/jupyter_client/session.py +++ b/jupyter_client/session.py @@ -30,6 +30,7 @@ from typing import Union import zmq.asyncio +from tornado.ioloop import IOLoop from traitlets import Any from traitlets import Bool from traitlets import CBytes @@ -46,7 +47,6 @@ from traitlets.config.configurable import LoggingConfigurable from traitlets.log import get_logger from traitlets.utils.importstring import import_item -from zmq.eventloop.ioloop import IOLoop from zmq.eventloop.zmqstream import ZMQStream from jupyter_client import protocol_version diff --git a/jupyter_client/threaded.py b/jupyter_client/threaded.py index f5b3f3773..e145d46ea 100644 --- a/jupyter_client/threaded.py +++ b/jupyter_client/threaded.py @@ -16,10 +16,10 @@ import nest_asyncio # type:ignore import zmq +from tornado.ioloop import IOLoop from traitlets import Instance from traitlets import Type from zmq import ZMQError -from zmq.eventloop import ioloop from zmq.eventloop import zmqstream from .session import Session @@ -48,7 +48,7 @@ def __init__( self, socket: Optional[zmq.Socket], session: Optional[Session], - loop: Optional[zmq.eventloop.ioloop.ZMQIOLoop], + loop: Optional[IOLoop], ) -> None: """Create a channel. @@ -121,7 +121,8 @@ def _handle_recv(self, future_msg: Awaitable) -> None: Unpacks message, and calls handlers with it. """ assert self.ioloop is not None - msg_list = self.ioloop._asyncio_event_loop.run_until_complete(get_msg(future_msg)) + loop = self.ioloop._asyncio_event_loop # type:ignore[attr-defined] + msg_list = loop.run_until_complete(get_msg(future_msg)) assert self.session is not None ident, smsg = self.session.feed_identities(msg_list) msg = self.session.deserialize(smsg) @@ -213,8 +214,8 @@ def run(self) -> None: loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) nest_asyncio.apply(loop) - self.ioloop = ioloop.IOLoop() - self.ioloop._asyncio_event_loop = loop + self.ioloop = IOLoop() + self.ioloop._asyncio_event_loop = loop # type:ignore[attr-defined] # signal that self.ioloop is defined self._start_event.set() while True: diff --git a/pyproject.toml b/pyproject.toml index 435d12fd8..797b23c86 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -128,7 +128,7 @@ filterwarnings= [ # Workaround for https://github.com/tornadoweb/tornado/issues/3106 # (To be fixed in Tornado 6.2) - "ignore:There is no current event loop:DeprecationWarning:tornado", + "ignore:There is no current event loop:DeprecationWarning", # ZMQ uses Future internally, which raises a DeprecationWarning # When there is no loop running. @@ -138,6 +138,8 @@ filterwarnings= [ # Workaround for jupyter_core warning. "module:Jupyter is migrating its paths to use standard platformdirs:DeprecationWarning", + + "ignore:zmq.tests.BaseZMQTestCase is deprecated in pyzmq 25:DeprecationWarning", ] [tool.mypy]