| 15 | @threading_helper.requires_working_threading() |
| 16 | class TestGC(TestCase): |
| 17 | def test_get_objects(self): |
| 18 | event = threading.Event() |
| 19 | |
| 20 | def gc_thread(): |
| 21 | for i in range(100): |
| 22 | o = gc.get_objects() |
| 23 | event.set() |
| 24 | |
| 25 | def mutator_thread(): |
| 26 | while not event.is_set(): |
| 27 | o1 = MyObj() |
| 28 | o2 = MyObj() |
| 29 | o3 = MyObj() |
| 30 | o4 = MyObj() |
| 31 | |
| 32 | gcs = [Thread(target=gc_thread)] |
| 33 | mutators = [Thread(target=mutator_thread) for _ in range(4)] |
| 34 | with threading_helper.start_threads(gcs + mutators): |
| 35 | pass |
| 36 | |
| 37 | def test_get_referrers(self): |
| 38 | NUM_GC = 2 |