PYZMQ memory leakage: 74/5174/1
authorimarom <[email protected]>
Mon, 19 Dec 2016 12:51:24 +0000 (14:51 +0200)
committerimarom <[email protected]>
Mon, 19 Dec 2016 12:52:56 +0000 (14:52 +0200)
see this:
https://github.com/zeromq/pyzmq/issues/767

and this:
https://github.com/minrk/pyzmq/commit/51bbb2d2e3197343d7cfe0aa6d500b61e63c7b01

Signed-off-by: imarom <[email protected]>
scripts/external_libs/pyzmq-14.5.0/python2/cel59/32bit/zmq/sugar/context.py
scripts/external_libs/pyzmq-14.5.0/python2/cel59/64bit/zmq/sugar/context.py
scripts/external_libs/pyzmq-14.5.0/python2/fedora18/64bit/zmq/sugar/context.py
scripts/external_libs/pyzmq-14.5.0/python3/cel59/32bit/zmq/sugar/context.py
scripts/external_libs/pyzmq-14.5.0/python3/cel59/64bit/zmq/sugar/context.py
scripts/external_libs/pyzmq-14.5.0/python3/fedora18/64bit/zmq/sugar/context.py

index 86a9c5d..692e025 100644 (file)
@@ -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):
index 86a9c5d..692e025 100644 (file)
@@ -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):
index 86a9c5d..692e025 100644 (file)
@@ -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):
index 86a9c5d..692e025 100644 (file)
@@ -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):
index 86a9c5d..692e025 100644 (file)
@@ -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):
index 86a9c5d..692e025 100644 (file)
@@ -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):