Skip to content

Commit 2f0a2eb

Browse files
committed
remove the heavy unit test which launches 4*1_000 os threads
1 parent 968a8d1 commit 2f0a2eb

1 file changed

Lines changed: 1 addition & 39 deletions

File tree

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import unittest
2-
import threading
3-
import _thread
42
from test.support import threading_helper
53

64
threading_helper.requires_working_threading(module=True)
@@ -9,6 +7,7 @@
97
class TestRlock(unittest.TestCase):
108
def test_repr_race(self):
119
# gh-153292
10+
import _thread
1211
r = _thread.RLock()
1312

1413
def repr_thread():
@@ -23,42 +22,5 @@ def mutate_thread():
2322
threading_helper.run_concurrently([repr_thread, mutate_thread])
2423

2524

26-
class TestShutdown(unittest.TestCase):
27-
def test_shutdown_race(self):
28-
ITERATIONS = 1_000
29-
STARTUP_THREADS = 4
30-
31-
def shutdown_worker():
32-
for _ in range(ITERATIONS):
33-
try:
34-
_thread._shutdown()
35-
except RuntimeError:
36-
pass
37-
38-
def startup_worker():
39-
for _ in range(ITERATIONS):
40-
handle = _thread.start_joinable_thread(
41-
lambda: None,
42-
daemon=False,
43-
)
44-
handle.join()
45-
46-
# The workers must be daemon threads so _thread._shutdown() ignores them
47-
# and only scans the non-daemon handles created by startup_worker().
48-
workers = [
49-
threading.Thread(target=shutdown_worker, daemon=True),
50-
*[
51-
threading.Thread(target=startup_worker, daemon=True)
52-
for _ in range(STARTUP_THREADS)
53-
],
54-
]
55-
56-
with threading_helper.catch_threading_exception() as cm:
57-
with threading_helper.start_threads(workers):
58-
pass
59-
if cm.exc_value is not None:
60-
raise cm.exc_value
61-
62-
6325
if __name__ == "__main__":
6426
unittest.main()

0 commit comments

Comments
 (0)