| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
# gh-115832: An object destructor running during the final GC of interpreter |
| 4 |
# shutdown triggered an infinite loop in the instrumentation code. |
| 5 |
|
| 6 |
import sys |
| 7 |
|
| 8 |
class CallableCycle: |
| 9 |
def __init__(self): |
| 10 |
self._cycle = self |
| 11 |
|
| 12 |
def __del__(self): |
| 13 |
pass |
| 14 |
|
| 15 |
def __call__(self, code, instruction_offset): |
| 16 |
pass |
| 17 |
|
| 18 |
def tracefunc(frame, event, arg): |
| 19 |
pass |
| 20 |
|
| 21 |
def main(): |
| 22 |
tool_id = sys.monitoring.PROFILER_ID |
| 23 |
event_id = sys.monitoring.events.PY_START |
| 24 |
|
| 25 |
sys.monitoring.use_tool_id(tool_id, "test profiler") |
| 26 |
sys.monitoring.set_events(tool_id, event_id) |
| 27 |
sys.monitoring.register_callback(tool_id, event_id, CallableCycle()) |
| 28 |
|
| 29 |
if __name__ == "__main__": |
| 30 |
sys.exit(main()) |