Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle classes having been torn down in atexit #336

Merged
merged 1 commit into from Jan 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion jupyter_client/channels.py
Expand Up @@ -80,7 +80,10 @@ def __init__(self, context=None, session=None, address=None):
@staticmethod
@atexit.register
def _notice_exit():
HBChannel._exiting = True
# Class definitions can be torn down during interpreter shutdown.
# We only need to set _exiting flag if this hasn't happened.
if HBChannel is not None:
HBChannel._exiting = True

def _create_socket(self):
if self.socket is not None:
Expand Down
5 changes: 4 additions & 1 deletion jupyter_client/threaded.py
Expand Up @@ -151,7 +151,10 @@ def __init__(self, loop):
@staticmethod
@atexit.register
def _notice_exit():
IOLoopThread._exiting = True
# Class definitions can be torn down during interpreter shutdown.
# We only need to set _exiting flag if this hasn't happened.
if IOLoopThread is not None:
IOLoopThread._exiting = True

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