Skip to content

Commit 2cb89fc

Browse files
committed
Trigger GC in multiprocessing test tearDown to lessen test interference
1 parent e10b3a7 commit 2cb89fc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

graalpython/lib-python/3/test/_test_multiprocessing.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import test.support
2828
import test.support.script_helper
2929
from test import support
30-
from test.support import hashlib_helper
30+
from test.support import hashlib_helper, gc_collect
3131
from test.support import import_helper
3232
from test.support import os_helper
3333
from test.support import socket_helper
@@ -5306,6 +5306,9 @@ def test_preload_resources(self):
53065306
@unittest.skipIf(sys.platform == "win32",
53075307
"test semantics don't make sense on Windows")
53085308
class TestResourceTracker(unittest.TestCase):
5309+
# GraalPy change: try trigger all the cleanup, or the leftover finalizers interfere with subsequent tests
5310+
def tearDown(self):
5311+
gc_collect()
53095312

53105313
def test_resource_tracker(self):
53115314
#
@@ -5407,7 +5410,7 @@ def check_resource_tracker_death(self, signum, should_die):
54075410
# ensure `sem` gets collected, which triggers communication with
54085411
# the semaphore tracker
54095412
del sem
5410-
gc.collect()
5413+
gc_collect()
54115414
self.assertIsNone(wr())
54125415
if should_die:
54135416
self.assertEqual(len(all_warn), 1)
@@ -5928,7 +5931,7 @@ def tearDownClass(cls):
59285931
f"active children after {dt} seconds")
59295932
break
59305933

5931-
gc.collect() # do garbage collection
5934+
gc_collect() # do garbage collection
59325935
if cls.manager._number_of_objects() != 0:
59335936
# This is not really an error since some tests do not
59345937
# ensure that all processes which hold a reference to a

0 commit comments

Comments
 (0)