Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
gh-136003: Execute pre-finalization callbacks in a loop#136004
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
354e6b5309052443038b88d4151cadd4d333edc3a8ec57918970153bcfd62b8859070f37098a08a1aa13cbcd55254613a19ccdb5f9cd75b71360059475538aa7941882dda7a4f1460af1e1301d51a20d4cf2dc1e6ea37928c12e6c8b87014e57bfdee2028480e66c88c8cac692ab28b0c9d5f4cFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -22,6 +22,7 @@ | ||
| from test import support | ||
| from test.support import MISSING_C_DOCSTRINGS | ||
| from test.support import import_helper | ||
| from test.support import script_helper | ||
| from test.support import threading_helper | ||
| from test.support import warnings_helper | ||
| from test.support import requires_limited_api | ||
| @@ -1641,6 +1642,36 @@ def subthread(): | ||
| self.assertEqual(actual, int(interpid)) | ||
| @threading_helper.requires_working_threading() | ||
| def test_pending_call_creates_thread(self): | ||
ZeroIntensity marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| source = """ | ||
| import _testinternalcapi | ||
| import threading | ||
| import time | ||
| def output(): | ||
| print(24) | ||
| time.sleep(1) | ||
| print(42) | ||
| def callback(): | ||
| threading.Thread(target=output).start() | ||
| def create_pending_call(): | ||
| time.sleep(1) | ||
| _testinternalcapi.simple_pending_call(callback) | ||
| threading.Thread(target=create_pending_call).start() | ||
| """ | ||
| return_code, stdout, stderr = script_helper.assert_python_ok('-c', textwrap.dedent(source)) | ||
| self.assertEqual(return_code, 0) | ||
| self.assertEqual(stdout, f"24{os.linesep}42{os.linesep}".encode("utf-8")) | ||
| self.assertEqual(stderr, b"") | ||
| class SubinterpreterTest(unittest.TestCase): | ||
| @@ -1949,6 +1980,41 @@ def test_module_state_shared_in_global(self): | ||
| subinterp_attr_id = os.read(r, 100) | ||
| self.assertEqual(main_attr_id, subinterp_attr_id) | ||
| @threading_helper.requires_working_threading() | ||
| @unittest.skipUnless(hasattr(os, "pipe"), "requires os.pipe()") | ||
| @requires_subinterpreters | ||
| def test_pending_call_creates_thread_subinterpreter(self): | ||
| interpreters = import_helper.import_module("concurrent.interpreters") | ||
| r, w = os.pipe() | ||
| source = f"""if True: | ||
| import _testinternalcapi | ||
| import threading | ||
| import time | ||
| import os | ||
| def output(): | ||
| time.sleep(1) | ||
| os.write({w}, b"x") | ||
| def callback(): | ||
| threading.Thread(target=output).start() | ||
| def create_pending_call(): | ||
| time.sleep(1) | ||
| _testinternalcapi.simple_pending_call(callback) | ||
| threading.Thread(target=create_pending_call).start() | ||
| """ | ||
| interp = interpreters.create() | ||
| interp.exec(source) | ||
| interp.close() | ||
| data = os.read(r, 1) | ||
| self.assertEqual(data, b"x") | ||
| @requires_subinterpreters | ||
| class InterpreterConfigTests(unittest.TestCase): | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Fix :class:`threading.Thread` objects becoming incorrectly daemon when | ||
| created from an :mod:`atexit` callback or a pending call | ||
| (:c:func:`Py_AddPendingCall`). |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.