An object that not only contains a reference cycle, but creates new cycles whenever it's garbage-collected and its __del__ runs
| 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()) |
no outgoing calls