Skip to content

Commit

Permalink
[7.x] Remove deprecated zmq imports (#916)
Browse files Browse the repository at this point in the history
* remove deprecated imports

* ignore dep warning in 7.x

* fix typing

* dep warning
  • Loading branch information
blink1073 authored Jan 12, 2023
1 parent edde6e0 commit 1f8bed3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion jupyter_client/ioloop/restarter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _loop_default(self):
DeprecationWarning,
stacklevel=4,
)
from zmq.eventloop import ioloop
from tornado import ioloop

return ioloop.IOLoop.current()

Expand Down
2 changes: 1 addition & 1 deletion jupyter_client/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
11 changes: 6 additions & 5 deletions jupyter_client/threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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]
Expand Down

0 comments on commit 1f8bed3

Please sign in to comment.