You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2023/02/09 05:14:35 UTC

[qpid-proton] branch main updated: PROTON-2095: Improve the Python CFFI Proton object wrapper

This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git


The following commit(s) were added to refs/heads/main by this push:
     new 4c23826ee PROTON-2095: Improve the Python CFFI Proton object wrapper
4c23826ee is described below

commit 4c23826ee6edadea0653837e0172ecb5131b8ef2
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Thu Feb 9 00:11:20 2023 -0500

    PROTON-2095: Improve the Python CFFI Proton object wrapper
    
    Make the python proton object wrapper a little smaller by removing asn
    unnecessary object.
    
    Eliminate a warning on exit by clearing the retained object set before
    the python exit object teardowns.
---
 python/cproton.py         | 4 ++++
 python/proton/_wrapper.py | 5 -----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/python/cproton.py b/python/cproton.py
index 5abcb11d6..ba973d0e0 100644
--- a/python/cproton.py
+++ b/python/cproton.py
@@ -17,6 +17,7 @@
 # under the License.
 #
 
+import atexit
 from uuid import UUID
 
 from cproton_ffi import ffi, lib
@@ -299,6 +300,9 @@ def pn_transport_set_pytracer(transport, tracer):
 retained_objects = set()
 lib.init()
 
+@atexit.register
+def clear_retained_objects():
+    retained_objects.clear()
 
 def retained_count():
     """ Debugging aid to give the number of wrapper objects retained by the bindings"""
diff --git a/python/proton/_wrapper.py b/python/proton/_wrapper.py
index f22f3fce2..9149e7562 100644
--- a/python/proton/_wrapper.py
+++ b/python/proton/_wrapper.py
@@ -47,8 +47,6 @@ class Wrapper(object):
         _impl   The wrapped C object itself
         _attrs  This is a special pn_record_t holding a PYCTX which is a python dict
                 every attribute in the python object is actually looked up here
-        _record This is the C record itself (so actually identical to _attrs really but
-                a different python type
 
         Because the objects actual attributes are stored away they must be initialised *after* the wrapping
         is set up. This is the purpose of the _init method in the wrapped  object. Wrapper.__init__ will call
@@ -70,7 +68,6 @@ class Wrapper(object):
             if impl is None:
                 self.__dict__["_impl"] = impl
                 self.__dict__["_attrs"] = EMPTY_ATTRS
-                self.__dict__["_record"] = None
                 raise ProtonException(
                     "Wrapper failed to create wrapped object. Check for file descriptor or memory exhaustion.")
             init = True
@@ -89,10 +86,8 @@ class Wrapper(object):
         else:
             attrs = EMPTY_ATTRS
             init = False
-            record = None
         self.__dict__["_impl"] = impl
         self.__dict__["_attrs"] = attrs
-        self.__dict__["_record"] = record
         if init:
             self._init()
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org