feature: replace __del__ with weakref.finalize()#4386
feature: replace __del__ with weakref.finalize()#4386maximilianluc wants to merge 1 commit intomicrosoft:masterfrom
Conversation
|
I think we can rename |
Codecov Report
@@ Coverage Diff @@
## master #4386 +/- ##
=======================================
Coverage 68.09% 68.09%
=======================================
Files 299 299
Lines 31535 31535
=======================================
Hits 21473 21473
Misses 10062 10062 |
|
@maximilianluc Thanks for this. It looks great but I will need a little bit of time to test this manually to see how it works in practice |
32a0ee5 to
52f080f
Compare
52f080f to
49d7082
Compare
|
@maximilianluc Sorry for the late response. I have spent a bit of time investigating this and unfortunately its a bit more complicated as the finalize method cannot contain a reference to self since that would increase the ref count to the instrument preventing the finalizer to be called. https://docs.python.org/3/library/weakref.html#weakref.finalize In #5341 I have implemented a partial solution for visa instruments that do not have this issue |
Feature addition: replacing del with weakref.finalize() as called method during object garbage collection.
Issue: #3774
__del__as__finalize, logic stays the same.__init__in instrument.py calling upon '__finalize()' during gc.