Ensure GC collections happen in a different thread, at a high frequency.
(period=0.005)
| 83 | |
| 84 | @contextlib.contextmanager |
| 85 | def collect_in_thread(period=0.005): |
| 86 | """ |
| 87 | Ensure GC collections happen in a different thread, at a high frequency. |
| 88 | """ |
| 89 | please_stop = False |
| 90 | |
| 91 | def collect(): |
| 92 | while not please_stop: |
| 93 | time.sleep(period) |
| 94 | gc.collect() |
| 95 | |
| 96 | with support.disable_gc(): |
| 97 | t = threading.Thread(target=collect) |
| 98 | t.start() |
| 99 | try: |
| 100 | yield |
| 101 | finally: |
| 102 | please_stop = True |
| 103 | t.join() |
| 104 | |
| 105 | |
| 106 | class ReferencesTestCase(TestBase): |
no test coverage detected
searching dependent graphs…