mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Revert "gh-128639: Don't assume one thread in subinterpreter finalization (gh-128640)" (gh-134256)
This reverts commit 9859791f9e
.
The original change broke the iOS and android buildbots, where the tests are run single-process.
This commit is contained in:
parent
871d269875
commit
27bd08273c
6 changed files with 38 additions and 99 deletions
|
@ -647,59 +647,6 @@ class TestInterpreterClose(TestBase):
|
|||
self.interp_exists(interpid))
|
||||
|
||||
|
||||
def test_remaining_threads(self):
|
||||
r_interp, w_interp = self.pipe()
|
||||
|
||||
FINISHED = b'F'
|
||||
|
||||
# It's unlikely, but technically speaking, it's possible
|
||||
# that the thread could've finished before interp.close() is
|
||||
# reached, so this test might not properly exercise the case.
|
||||
# However, it's quite unlikely and I'm too lazy to deal with it.
|
||||
interp = interpreters.create()
|
||||
interp.exec(f"""if True:
|
||||
import os
|
||||
import threading
|
||||
import time
|
||||
|
||||
def task():
|
||||
time.sleep(1)
|
||||
os.write({w_interp}, {FINISHED!r})
|
||||
|
||||
threads = [threading.Thread(target=task) for _ in range(3)]
|
||||
for t in threads:
|
||||
t.start()
|
||||
""")
|
||||
interp.close()
|
||||
|
||||
self.assertEqual(os.read(r_interp, 1), FINISHED)
|
||||
|
||||
def test_remaining_daemon_threads(self):
|
||||
interp = _interpreters.create(
|
||||
types.SimpleNamespace(
|
||||
use_main_obmalloc=False,
|
||||
allow_fork=False,
|
||||
allow_exec=False,
|
||||
allow_threads=True,
|
||||
allow_daemon_threads=True,
|
||||
check_multi_interp_extensions=True,
|
||||
gil='own',
|
||||
)
|
||||
)
|
||||
_interpreters.exec(interp, f"""if True:
|
||||
import threading
|
||||
import time
|
||||
|
||||
def task():
|
||||
time.sleep(100)
|
||||
|
||||
threads = [threading.Thread(target=task, daemon=True) for _ in range(3)]
|
||||
for t in threads:
|
||||
t.start()
|
||||
""")
|
||||
_interpreters.destroy(interp)
|
||||
|
||||
|
||||
class TestInterpreterPrepareMain(TestBase):
|
||||
|
||||
def test_empty(self):
|
||||
|
@ -808,10 +755,7 @@ class TestInterpreterExec(TestBase):
|
|||
spam.eggs()
|
||||
|
||||
interp = interpreters.create()
|
||||
try:
|
||||
interp.exec(script)
|
||||
finally:
|
||||
interp.close()
|
||||
interp.exec(script)
|
||||
""")
|
||||
|
||||
stdout, stderr = self.assert_python_failure(scriptfile)
|
||||
|
@ -820,7 +764,7 @@ class TestInterpreterExec(TestBase):
|
|||
# File "{interpreters.__file__}", line 179, in exec
|
||||
self.assertEqual(stderr, dedent(f"""\
|
||||
Traceback (most recent call last):
|
||||
File "{scriptfile}", line 10, in <module>
|
||||
File "{scriptfile}", line 9, in <module>
|
||||
interp.exec(script)
|
||||
~~~~~~~~~~~^^^^^^^^
|
||||
{interpmod_line.strip()}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue