summaryrefslogtreecommitdiffstats
path: root/scripts/external_libs/pyzmq-14.5.0/python2/fedora18/64bit/zmq/sugar/context.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/external_libs/pyzmq-14.5.0/python2/fedora18/64bit/zmq/sugar/context.py')
-rw-r--r--scripts/external_libs/pyzmq-14.5.0/python2/fedora18/64bit/zmq/sugar/context.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/scripts/external_libs/pyzmq-14.5.0/python2/fedora18/64bit/zmq/sugar/context.py b/scripts/external_libs/pyzmq-14.5.0/python2/fedora18/64bit/zmq/sugar/context.py
index 86a9c5dc..692e0256 100644
--- a/scripts/external_libs/pyzmq-14.5.0/python2/fedora18/64bit/zmq/sugar/context.py
+++ b/scripts/external_libs/pyzmq-14.5.0/python2/fedora18/64bit/zmq/sugar/context.py
@@ -5,7 +5,6 @@
# Distributed under the terms of the Modified BSD License.
import atexit
-import weakref
from zmq.backend import Context as ContextBase
from . import constants
@@ -14,6 +13,14 @@ from .constants import ENOTSUP, ctx_opt_names
from .socket import Socket
from zmq.error import ZMQError
+# notice when exiting, to avoid triggering term on exit
+_exiting = False
+def _notice_atexit():
+ global _exiting
+ _exiting = True
+atexit.register(_notice_atexit)
+
+
from zmq.utils.interop import cast_int_addr
@@ -25,7 +32,6 @@ class Context(ContextBase, AttributeSetter):
sockopts = None
_instance = None
_shadow = False
- _exiting = False
def __init__(self, io_threads=1, **kwargs):
super(Context, self).__init__(io_threads=io_threads, **kwargs)
@@ -35,18 +41,10 @@ class Context(ContextBase, AttributeSetter):
self._shadow = False
self.sockopts = {}
- self._exiting = False
- if not self._shadow:
- ctx_ref = weakref.ref(self)
- def _notify_atexit():
- ctx = ctx_ref()
- if ctx is not None:
- ctx._exiting = True
- atexit.register(_notify_atexit)
def __del__(self):
"""deleting a Context should terminate it, without trying non-threadsafe destroy"""
- if not self._shadow and not self._exiting:
+ if not self._shadow and not _exiting:
self.term()
def __enter__(self):