Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 38e3e0f

Browse files
committed
TST: add a test in a new test_multithreading module
1 parent ebf008a commit 38e3e0f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import concurrent.futures
2+
3+
import numpy as np
4+
5+
6+
def test_parallel_errstate_creation():
7+
# if the coercion cache is enabled and not thread-safe, creating RandomState
8+
# instances simultaneously leads to a data race
9+
def func(seed):
10+
np.random.RandomState(seed)
11+
12+
with concurrent.futures.ThreadPoolExecutor(max_workers=8) as tpe:
13+
futures = [tpe.submit(func, i) for i in range(500)]
14+
for f in futures:
15+
f.result()

0 commit comments

Comments
 (0)