Skip to content

Commit 0b773dd

Browse files
committed
try again
1 parent dc47363 commit 0b773dd

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

jupyter_client/client.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Copyright (c) Jupyter Development Team.
33
# Distributed under the terms of the Modified BSD License.
44
import asyncio
5+
import atexit
56
import sys
67
import time
78
import typing as t
@@ -93,7 +94,9 @@ class KernelClient(ConnectionFileMixin):
9394
context = Instance(zmq.asyncio.Context)
9495

9596
def _context_default(self) -> zmq.asyncio.Context:
96-
return zmq.asyncio.Context()
97+
context = zmq.asyncio.Context()
98+
atexit.register(context.destroy)
99+
return context
97100

98101
# The classes to use for the various channels
99102
shell_channel_class = Type(ChannelABC)
@@ -112,10 +115,6 @@ def _context_default(self) -> zmq.asyncio.Context:
112115
# flag for whether execute requests should be allowed to call raw_input:
113116
allow_stdin: bool = True
114117

115-
def __del__(self):
116-
"""Destroy our context when we are garbage collected."""
117-
self.context.destroy()
118-
119118
# --------------------------------------------------------------------------
120119
# Channel proxy methods
121120
# --------------------------------------------------------------------------

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ filterwarnings= [
4141
# Fail on warnings
4242
"error",
4343

44+
# We're missing an event loop close somewhere.
45+
"ignore:unclosed <socket.socket:ResourceWarning",
46+
"ignore:unclosed event loop:ResourceWarning",
47+
4448
# Workaround for https://github.com/tornadoweb/tornado/issues/3106
4549
# (To be fixed in Tornado 6.2)
4650
"ignore:There is no current event loop:DeprecationWarning:tornado",
4751

48-
# Randomly occuring.
49-
"ignore:unclosed <socket.socket:ResourceWarning",
50-
5152
# ZMQ uses Future internally, which raises a DeprecationWarning
5253
# When there is no loop running.
5354
# We could eventually find a way to make sure these are only created

0 commit comments

Comments
 (0)