# Distributed under the terms of the Modified BSD License.
import atexit
-import weakref
from zmq.backend import Context as ContextBase
from . import constants
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
sockopts = None
_instance = None
_shadow = False
- _exiting = False
def __init__(self, io_threads=1, **kwargs):
super(Context, self).__init__(io_threads=io_threads, **kwargs)
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):
# Distributed under the terms of the Modified BSD License.
import atexit
-import weakref
from zmq.backend import Context as ContextBase
from . import constants
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
sockopts = None
_instance = None
_shadow = False
- _exiting = False
def __init__(self, io_threads=1, **kwargs):
super(Context, self).__init__(io_threads=io_threads, **kwargs)
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):
# Distributed under the terms of the Modified BSD License.
import atexit
-import weakref
from zmq.backend import Context as ContextBase
from . import constants
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
sockopts = None
_instance = None
_shadow = False
- _exiting = False
def __init__(self, io_threads=1, **kwargs):
super(Context, self).__init__(io_threads=io_threads, **kwargs)
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):
# Distributed under the terms of the Modified BSD License.
import atexit
-import weakref
from zmq.backend import Context as ContextBase
from . import constants
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
sockopts = None
_instance = None
_shadow = False
- _exiting = False
def __init__(self, io_threads=1, **kwargs):
super(Context, self).__init__(io_threads=io_threads, **kwargs)
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):
# Distributed under the terms of the Modified BSD License.
import atexit
-import weakref
from zmq.backend import Context as ContextBase
from . import constants
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
sockopts = None
_instance = None
_shadow = False
- _exiting = False
def __init__(self, io_threads=1, **kwargs):
super(Context, self).__init__(io_threads=io_threads, **kwargs)
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):
# Distributed under the terms of the Modified BSD License.
import atexit
-import weakref
from zmq.backend import Context as ContextBase
from . import constants
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
sockopts = None
_instance = None
_shadow = False
- _exiting = False
def __init__(self, io_threads=1, **kwargs):
super(Context, self).__init__(io_threads=io_threads, **kwargs)
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):