MCPcopy Create free account
hub / github.com/numpy/numpy / ReferenceCycleInDel

Class ReferenceCycleInDel

numpy/testing/tests/test_utils.py:1592–1609  ·  view source on GitHub ↗

An object that not only contains a reference cycle, but creates new cycles whenever it's garbage-collected and its __del__ runs

Source from the content-addressed store, hash-verified

1590 """
1591
1592 class ReferenceCycleInDel:
1593 """
1594 An object that not only contains a reference cycle, but creates new
1595 cycles whenever it's garbage-collected and its __del__ runs
1596 """
1597 make_cycle = True
1598
1599 def __init__(self):
1600 self.cycle = self
1601
1602 def __del__(self):
1603 # break the current cycle so that `self` can be freed
1604 self.cycle = None
1605
1606 if ReferenceCycleInDel.make_cycle:
1607 # but create a new one so that the garbage collector has more
1608 # work to do.
1609 ReferenceCycleInDel()
1610
1611 try:
1612 w = weakref.ref(ReferenceCycleInDel())

Callers 2

__del__Method · 0.85
test_failsMethod · 0.85

Calls

no outgoing calls

Tested by 2

__del__Method · 0.68
test_failsMethod · 0.68