Skip to content

Commit

Permalink
TST: add a test in a new test_multithreading module
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoldbaum committed Apr 18, 2024
1 parent ebf008a commit 9fce93a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions numpy/_core/tests/test_multithreading.py
@@ -0,0 +1,15 @@
import concurrent.futures

import numpy as np


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()

0 comments on commit 9fce93a

Please sign in to comment.