Skip to content

Commit aeb6447

Browse files
vstinnergrzgrzgrz3
andauthored
bpo-30357: test_thread now uses threading_cleanup() (#1592) (#1623)
test_thread: setUp() now uses support.threading_setup() and support.threading_cleanup() to wait until threads complete to avoid random side effects on following tests. Co-Authored-By: Grzegorz Grzywacz <[email protected]> (cherry picked from commit 79ef7f8)
1 parent c9ba45d commit aeb6447

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

Lib/test/test_thread.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def verbose_print(arg):
2020
with _print_mutex:
2121
print(arg)
2222

23+
2324
class BasicThreadTest(unittest.TestCase):
2425

2526
def setUp(self):
@@ -31,6 +32,9 @@ def setUp(self):
3132
self.running = 0
3233
self.next_ident = 0
3334

35+
key = support.threading_setup()
36+
self.addCleanup(support.threading_cleanup, *key)
37+
3438

3539
class ThreadRunningTests(BasicThreadTest):
3640

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ Eric Groo
543543
Daniel Andrade Groppe
544544
Dag Gruneau
545545
Filip Gruszczyński
546+
Grzegorz Grzywacz
546547
Thomas Guettler
547548
Yuyang Guo
548549
Anuj Gupta

Misc/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ Build
235235
Tests
236236
-----
237237

238+
- bpo-30357: test_thread: setUp() now uses support.threading_setup() and
239+
support.threading_cleanup() to wait until threads complete to avoid
240+
random side effects on following tests. Initial patch written by Grzegorz
241+
Grzywacz.
242+
238243
- bpo-28087: Skip test_asyncore and test_eintr poll failures on macOS.
239244
Skip some tests of select.poll when running on macOS due to unresolved
240245
issues with the underlying system poll function on some macOS versions.

0 commit comments

Comments
 (0)