Skip to content

Commit 66982eb

Browse files
committed
garbage collection is a bit different on 3.11
- different refcount increment for calling a function - __del__ is called in different circumstances
1 parent 1c1882f commit 66982eb

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

zmq/sugar/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def __repr__(self) -> str:
8181
_repr_cls = f"{cls.__module__}.{cls.__name__}"
8282

8383
closed = ' closed' if self.closed else ''
84-
if self._sockets:
84+
if getattr(self, "_sockets", None):
8585
n_sockets = len(self._sockets)
8686
s = 's' if n_sockets > 1 else ''
8787
sockets = f"{n_sockets} socket{s}"

zmq/tests/test_message.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ def await_gc(obj, rc):
3737
Necessary because of the zero-copy gc thread,
3838
which can take some time to receive its DECREF message.
3939
"""
40+
# count refs for this function
41+
if sys.version_info < (3, 11):
42+
my_refs = 2
43+
else:
44+
my_refs = 1
4045
for i in range(50):
4146
# rc + 2 because of the refs in this function
42-
if grc(obj) <= rc + 2:
47+
if grc(obj) <= rc + my_refs:
4348
return
4449
time.sleep(0.05)
4550

0 commit comments

Comments
 (0)