Skip to content

Commit f85a291

Browse files
committed
Run the daemon thread test in a subprocess.
1 parent 0146aec commit f85a291

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Lib/test/test_interpreters/test_api.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from test import support
99
from test.support import import_helper
10+
from test.support.script_helper import assert_python_ok
1011
# Raise SkipTest if subinterpreters not supported.
1112
_interpreters = import_helper.import_module('_interpreters')
1213
from test.support import Py_GIL_DISABLED
@@ -675,6 +676,13 @@ def task():
675676
self.assertEqual(os.read(r_interp, 1), FINISHED)
676677

677678
def test_remaining_daemon_threads(self):
679+
# Daemon threads leak reference by nature, because they hang threads
680+
# without allowing them to do cleanup (i.e., release refs).
681+
# To prevent that from messing up the refleak hunter and whatnot, we
682+
# run this in a subprocess.
683+
code = '''if True:
684+
import _interpreters
685+
import types
678686
interp = _interpreters.create(
679687
types.SimpleNamespace(
680688
use_main_obmalloc=False,
@@ -698,6 +706,8 @@ def task():
698706
t.start()
699707
""")
700708
_interpreters.destroy(interp)
709+
'''
710+
assert_python_ok('-c', code)
701711

702712

703713
class TestInterpreterPrepareMain(TestBase):

0 commit comments

Comments
 (0)