10000 BUG: fix race initializing legacy dtype casts by charris · Pull Request #28321 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: fix race initializing legacy dtype casts #28321

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

Merged
merged 15 commits into from
Feb 11, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension 10000

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
MAINT: use a try/finally to make the deadlock protection more robust
  • Loading branch information
ngoldbaum authored and charris committed Feb 11, 2025
commit c20ac888de1d45c44c8d3a0e972a23e781a322ec
21 changes: 11 additions & 10 deletions numpy/testing/_private/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2699,18 +2699,19 @@ def run_threaded(func, max_workers=8, pass_count=False,
if pass_barrier:
barrier = threading.Barrier(max_workers)
args.append(barrier)
if pass_count:
all_args = [(func, i, *args) for i in range(max_workers)]
else:
all_args = [(func, *args) for i in range(max_workers)]
try:
if pass_count:
futures = [tpe.submit(func, i, *args) for i in
range(max_workers)]
else:
futures = [tpe.submit(func, *args) for _ in
range(max_workers)]
except RuntimeError:
# python raises RuntimeError when it can't spawn new threads
if pass_barrier:
n_submitted = 0
futures = []
for arg in all_args:
futures.append(tpe.submit(*arg))
n_submitted += 1
finally:
if n_submitted < max_workers and pass_barrier:
barrier.abort()
raise
for f in futures:
f.result()

Expand Down
0