]> granicus.if.org Git - python/commitdiff
Added a provision to stop all threads before exiting from the test:
authorGuido van Rossum <guido@python.org>
Mon, 24 Apr 2000 14:07:03 +0000 (14:07 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 24 Apr 2000 14:07:03 +0000 (14:07 +0000)
the change to regrtest.py to unload all newly imported modules did
something bad to the threads -- and I realized that they would never
stop!

Lib/test/test_fork1.py

index c0e5b44966665d7829dbf9f7f4d2f6d4dc31d3e5..0d20fb3a6df8998b5cbedf76ef65d5418b201c7f 100644 (file)
@@ -18,8 +18,10 @@ NUM_THREADS = 4
 
 alive = {}
 
+stop = 0
+
 def f(id):
-    while 1:
+    while not stop:
         alive[id] = os.getpid()
         try:
             time.sleep(SHORTSLEEP)
@@ -53,5 +55,9 @@ def main():
         spid, status = os.waitpid(cpid, 0)
         assert spid == cpid
         assert status == 0, "cause = %d, exit = %d" % (status&0xff, status>>8)
+        global stop
+        # Tell threads to die
+        stop = 1
+        time.sleep(2*SHORTSLEEP) # Wait for threads to die
 
 main()