File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 2
2
# Copyright (c) Jupyter Development Team.
3
3
# Distributed under the terms of the Modified BSD License.
4
4
import asyncio
5
+ import atexit
5
6
import sys
6
7
import time
7
8
import typing as t
@@ -93,7 +94,9 @@ class KernelClient(ConnectionFileMixin):
93
94
context = Instance (zmq .asyncio .Context )
94
95
95
96
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
97
100
98
101
# The classes to use for the various channels
99
102
shell_channel_class = Type (ChannelABC )
@@ -112,10 +115,6 @@ def _context_default(self) -> zmq.asyncio.Context:
112
115
# flag for whether execute requests should be allowed to call raw_input:
113
116
allow_stdin : bool = True
114
117
115
- def __del__ (self ):
116
- """Destroy our context when we are garbage collected."""
117
- self .context .destroy ()
118
-
119
118
# --------------------------------------------------------------------------
120
119
# Channel proxy methods
121
120
# --------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -41,13 +41,14 @@ filterwarnings= [
41
41
# Fail on warnings
42
42
" error" ,
43
43
44
+ # We're missing an event loop close somewhere.
45
+ " ignore:unclosed <socket.socket:ResourceWarning" ,
46
+ " ignore:unclosed event loop:ResourceWarning" ,
47
+
44
48
# Workaround for https://github.com/tornadoweb/tornado/issues/3106
45
49
# (To be fixed in Tornado 6.2)
46
50
" ignore:There is no current event loop:DeprecationWarning:tornado" ,
47
51
48
- # Randomly occuring.
49
- " ignore:unclosed <socket.socket:ResourceWarning" ,
50
-
51
52
# ZMQ uses Future internally, which raises a DeprecationWarning
52
53
# When there is no loop running.
53
54
# We could eventually find a way to make sure these are only created
You can’t perform that action at this time.
0 commit comments