Skip to content

Commit 690f45b

Browse files
committed
Some small changes to the test.
1 parent 29c90eb commit 690f45b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Lib/test/test_free_threading/test_generators.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
import unittest
2-
import concurrent.futures
32

43
from unittest import TestCase
54

65
from test.support import threading_helper
76

87
@threading_helper.requires_working_threading()
98
class TestGen(TestCase):
10-
def test_generators_basic(self):
9+
def test_generator_send(self):
10+
import threading
11+
1112
def gen():
1213
for _ in range(5000):
1314
yield
1415

1516

1617
it = gen()
17-
with concurrent.futures.ThreadPoolExecutor() as executor:
18-
for _ in range(5000):
19-
executor.submit(lambda: next(it))
18+
with threading_helper.catch_threading_exception() as cm:
19+
# next(it) is equivalent to it.send(None)
20+
with threading_helper.start_threads(
21+
(threading.Thread(target=lambda: next(it)) for _ in range(10))
22+
):
23+
pass
24+
25+
self.assertIsNone(cm.exc_value)
2026

2127

2228
if __name__ == "__main__":

0 commit comments

Comments
 (0)