Skip to content

Lock the set_num_threads() to prevent dead-locks in parallel environments - #572

Open
kif wants to merge 2 commits into
pydata:masterfrom
kif:lock_set_pool_size
Open

kif wants to merge 2 commits into
pydata:masterfrom
kif:lock_set_pool_size

Conversation

@kif

@kif kif commented Sep 27, 2026

Copy link
Copy Markdown

Has been observed in pytest while debugging #569.
Related to #571

First implement a regression test when setting pool size from several threads. Sorry this test is pretty slow. It might also cause time-out instead of failing.

@deepkilo

Copy link
Copy Markdown

Additional downstream validation for this PR and #570, from numerical/concurrency qualification of our quantitative-research runtime. This is executed workload evidence, not a claim that source review alone establishes safety.

On Linux x86_64, GIL CPython 3.15.0 / NumPy 2.5.4, our local NumExpr 2.14.2 build combines the reviewed #570/#572 changes with additional fork-child state handling and the separate integer fixes. A bounded test shared one compiled signal / norm + dummy expression among four Python threads (12 synchronized calls each, 16,384-element arrays) while the main thread resized the native pool through [2, 1, 4, 1] three times. Results matched NumPy and all threads completed.

A separate child-liveness check reused a compiled expression after a fork while a parent thread was evaluating it; it completed with the additional child-state repair. That result must not be attributed to #570 or #572 alone. CPython emits its expected multithreaded-fork warning, and this does not make arbitrary multithreaded fork safe.

These are combined-build integration checks, not independent proof of each PR, a multiple-concurrent-setter test, a free-threaded-Python result, or a universal thread-safety guarantee. Posting once here rather than duplicating the same report on #570.

Disclosure: OpenAI Codex (GPT-6 family; exact variant/effort unavailable) assisted with investigation, test execution and drafting. No manual-operator-review claim is intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants