An object that not only contains a reference cycle, but creates new cycles whenever it's garbage-collected and its __del__ runs
| 2111 | """ |
| 2112 | |
| 2113 | class ReferenceCycleInDel: |
| 2114 | """ |
| 2115 | An object that not only contains a reference cycle, but creates new |
| 2116 | cycles whenever it's garbage-collected and its __del__ runs |
| 2117 | """ |
| 2118 | make_cycle = True |
| 2119 | |
| 2120 | def __init__(self): |
| 2121 | self.cycle = self |
| 2122 | |
| 2123 | def __del__(self): |
| 2124 | # break the current cycle so that `self` can be freed |
| 2125 | self.cycle = None |
| 2126 | |
| 2127 | if ReferenceCycleInDel.make_cycle: |
| 2128 | # but create a new one so that the garbage collector (GC) has more |
| 2129 | # work to do. |
| 2130 | ReferenceCycleInDel() |
| 2131 | |
| 2132 | try: |
| 2133 | w = weakref.ref(ReferenceCycleInDel()) |
no outgoing calls
searching dependent graphs…