summaryrefslogtreecommitdiffstats
path: root/scripts/external_libs/pyzmq-14.5.0/python2/cel59/64bit/zmq/sugar
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-12-19 14:51:24 +0200
committerimarom <imarom@cisco.com>2016-12-19 14:52:56 +0200
commita28ff745cc2a45df81bb34a56ca0294ece0b4087 (patch)
treecbd12be4122e08466b9a56c0428ced5d5a16560c /scripts/external_libs/pyzmq-14.5.0/python2/cel59/64bit/zmq/sugar
parent5cfeb192a3ff47c5cacc21abe20db2f61a66dd2b (diff)
PYZMQ memory leakage:
see this: https://github.com/zeromq/pyzmq/issues/767 and this: https://github.com/minrk/pyzmq/commit/51bbb2d2e3197343d7cfe0aa6d500b61e63c7b01 Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'scripts/external_libs/pyzmq-14.5.0/python2/cel59/64bit/zmq/sugar')
-rw-r--r--scripts/external_libs/pyzmq-14.5.0/python2/cel59/64bit/zmq/sugar/context.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/scripts/external_libs/pyzmq-14.5.0/python2/cel59/64bit/zmq/sugar/context.py b/scripts/external_libs/pyzmq-14.5.0/python2/cel59/64bit/zmq/sugar/context.py
index 86a9c5dc..692e0256 100644
--- a/scripts/external_libs/pyzmq-14.5.0/python2/cel59/64bit/zmq/sugar/context.py
+++ b/scripts/external_libs/pyzmq-14.5.0/python2/cel59/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):