Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-128639: Don't assume one thread in subinterpreter finalization with fixed daemon thread support #134606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
Loading
from
Prev Previous commit
Next Next commit
Run the daemon thread test in a subprocess.
  • Loading branch information
ZeroIntensity committed May 25, 2025
commit f85a291b5d70e8b25ac89342aff708c87fc95ba0
10 changes: 10 additions & 0 deletions 10 Lib/test/test_interpreters/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from test import support
from test.support import import_helper
from test.support.script_helper import assert_python_ok
# Raise SkipTest if subinterpreters not supported.
_interpreters = import_helper.import_module('_interpreters')
from test.support import Py_GIL_DISABLED
Expand Down Expand Up @@ -675,6 +676,13 @@ def task():
self.assertEqual(os.read(r_interp, 1), FINISHED)

def test_remaining_daemon_threads(self):
# Daemon threads leak reference by nature, because they hang threads
# without allowing them to do cleanup (i.e., release refs).
# To prevent that from messing up the refleak hunter and whatnot, we
# run this in a subprocess.
code = '''if True:
import _interpreters
import types
interp = _interpreters.create(
types.SimpleNamespace(
use_main_obmalloc=False,
Expand All @@ -698,6 +706,8 @@ def task():
t.start()
""")
_interpreters.destroy(interp)
'''
assert_python_ok('-c', code)


class TestInterpreterPrepareMain(TestBase):
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.