Skip to content

Commit 87a90f3

Browse files
committed
Use threading_helper.run_concurrently.
1 parent def0f47 commit 87a90f3

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

Lib/test/test_free_threading/test_bisect.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def insert(data):
1919
insert_method(data, x)
2020

2121
data = list(range(OBJECT_COUNT))
22-
self.run_concurrently(
22+
threading_helper.run_concurrently(
2323
worker_func=insert, args=(data,), nthreads=NTHREADS
2424
)
2525
if False:
@@ -42,28 +42,6 @@ def is_sorted_ascending(lst):
4242
"""
4343
return all(lst[i - 1] <= lst[i] for i in range(1, len(lst)))
4444

45-
def run_concurrently(self, worker_func, args, nthreads):
46-
"""
47-
Run the worker function concurrently in multiple threads.
48-
"""
49-
barrier = Barrier(nthreads)
50-
51-
def wrapper_func(*args):
52-
# Wait for all threads to reach this point before proceeding.
53-
barrier.wait()
54-
worker_func(*args)
55-
56-
with threading_helper.catch_threading_exception() as cm:
57-
workers = (
58-
Thread(target=wrapper_func, args=args)
59-
for _ in range(nthreads)
60-
)
61-
with threading_helper.start_threads(workers):
62-
pass
63-
64-
# Worker threads should not raise any exceptions
65-
self.assertIsNone(cm.exc_value)
66-
6745

6846
@threading_helper.requires_working_threading()
6947
class TestPyBisect(unittest.TestCase, TestBase):

0 commit comments

Comments
 (0)