forked from numpy/numpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request numpy#26294 from ngoldbaum/disable-coercion-cache
MNT: disable the coercion cache for the nogil build
- Loading branch information
Showing
2 changed files
with
33 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import concurrent.futures | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
from numpy.testing import IS_WASM | ||
|
||
if IS_WASM: | ||
pytest.skip(allow_module_level=True, reason="no threading support in wasm") | ||
|
||
|
||
def test_parallel_errstate_creation(): | ||
# if the coercion cache is enabled and not thread-safe, creating | ||
# RandomState instances simultaneously leads to a data race | ||
def func(seed): | ||
np.random.RandomState(seed) | ||
|
||
with concurrent.futures.ThreadPoolExecutor(max_workers=8) as tpe: | ||
futures = [tpe.submit(func, i) for i in range(500)] | ||
for f in futures: | ||
f.result() |