Skip to content

Commit 8f2d85e

Browse files
Move test to test_types.py
1 parent 0fc508e commit 8f2d85e

2 files changed

Lines changed: 21 additions & 31 deletions

File tree

Lib/test/test_free_threading/test_genericalias.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

Lib/test/test_free_threading/test_types.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import unittest
2+
import threading
23
from typing import TypeVar
34
from test.support import threading_helper
45

56
threading_helper.requires_working_threading(module=True)
67

8+
NTHREADS = 10
9+
710

811
class TestGenericAlias(unittest.TestCase):
912
def test_parameters_race(self):
@@ -28,6 +31,24 @@ def refresh():
2831
*[refresh for _ in range(2)],
2932
])
3033

34+
def test_shared_generic_alias_iter(self):
35+
# See https://github.com/python/cpython/issues/154043
36+
def worker(it, barrier):
37+
barrier.wait()
38+
try:
39+
next(it)
40+
except StopIteration:
41+
pass
42+
bar = threading.Barrier(NTHREADS)
43+
44+
bar = threading.Barrier(NTHREADS)
45+
number_of_iterations = 50
46+
for _ in range(number_of_iterations):
47+
shared = iter(list[int])
48+
threading_helper.run_concurrently(
49+
worker_func=worker, nthreads=NTHREADS, args=(shared, bar)
50+
)
51+
3152

3253
if __name__ == "__main__":
3354
unittest.main()

0 commit comments

Comments
 (0)