mirror of
https://github.com/python/cpython.git
synced 2025-12-09 10:37:17 +00:00
Added a provision to stop all threads before exiting from the test:
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!
This commit is contained in:
parent
9d90a94faf
commit
c1488413e4
1 changed files with 7 additions and 1 deletions
|
|
@ -18,8 +18,10 @@ NUM_THREADS = 4
|
||||||
|
|
||||||
alive = {}
|
alive = {}
|
||||||
|
|
||||||
|
stop = 0
|
||||||
|
|
||||||
def f(id):
|
def f(id):
|
||||||
while 1:
|
while not stop:
|
||||||
alive[id] = os.getpid()
|
alive[id] = os.getpid()
|
||||||
try:
|
try:
|
||||||
time.sleep(SHORTSLEEP)
|
time.sleep(SHORTSLEEP)
|
||||||
|
|
@ -53,5 +55,9 @@ def main():
|
||||||
spid, status = os.waitpid(cpid, 0)
|
spid, status = os.waitpid(cpid, 0)
|
||||||
assert spid == cpid
|
assert spid == cpid
|
||||||
assert status == 0, "cause = %d, exit = %d" % (status&0xff, status>>8)
|
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()
|
main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue