File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change 1313"""
1414
1515import os , sys , time , unittest
16- import test .test_support as test_support
17- thread = test_support .import_module ('thread' )
16+ import test .support as support
17+
18+ threading = support .import_module ('threading' )
1819
1920LONGSLEEP = 2
2021SHORTSLEEP = 0.5
2324class ForkWait (unittest .TestCase ):
2425
2526 def setUp (self ):
27+ self ._threading_key = support .threading_setup ()
2628 self .alive = {}
2729 self .stop = 0
30+ self .threads = []
31+
32+ def tearDown (self ):
33+ # Stop threads
34+ self .stop = 1
35+ for thread in self .threads :
36+ thread .join ()
37+ thread = None
38+ del self .threads [:]
39+ support .threading_cleanup (* self ._threading_key )
2840
2941 def f (self , id ):
3042 while not self .stop :
@@ -48,7 +60,9 @@ def wait_impl(self, cpid):
4860
4961 def test_wait (self ):
5062 for i in range (NUM_THREADS ):
51- thread .start_new (self .f , (i ,))
63+ thread = threading .Thread (target = self .f , args = (i ,))
64+ thread .start ()
65+ self .threads .append (thread )
5266
5367 time .sleep (LONGSLEEP )
5468
@@ -74,6 +88,3 @@ def test_wait(self):
7488 else :
7589 # Parent
7690 self .wait_impl (cpid )
77- # Tell threads to die
78- self .stop = 1
79- time .sleep (2 * SHORTSLEEP ) # Wait for threads to die
You can’t perform that action at this time.
0 commit comments