Skip to content

Commit 7b1114a

Browse files
authored
Merge pull request #337 from jupyter/auto-backport-of-pr-336
Backport PR #336 on branch 5.x
2 parents fc4bd44 + 3be0c4c commit 7b1114a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

jupyter_client/channels.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ def __init__(self, context=None, session=None, address=None):
8080
@staticmethod
8181
@atexit.register
8282
def _notice_exit():
83-
HBChannel._exiting = True
83+
# Class definitions can be torn down during interpreter shutdown.
84+
# We only need to set _exiting flag if this hasn't happened.
85+
if HBChannel is not None:
86+
HBChannel._exiting = True
8487

8588
def _create_socket(self):
8689
if self.socket is not None:

jupyter_client/threaded.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ def __init__(self, loop):
151151
@staticmethod
152152
@atexit.register
153153
def _notice_exit():
154-
IOLoopThread._exiting = True
154+
# Class definitions can be torn down during interpreter shutdown.
155+
# We only need to set _exiting flag if this hasn't happened.
156+
if IOLoopThread is not None:
157+
IOLoopThread._exiting = True
155158

156159
def run(self):
157160
"""Run my loop, ignoring EINTR events in the poller"""

0 commit comments

Comments
 (0)