mirror of
https://github.com/python/cpython.git
synced 2025-11-02 11:08:57 +00:00
Prevent spurious leaks when running regrtest.py -R. There may be more
issues that crop up from time to time, but this change seems to have been pretty stable (no spurious warnings) for about a week. Other modules which use threads may require similar use of threading_setup/threading_cleanup from test_support.
This commit is contained in:
parent
f5da071ec8
commit
9602cc2aa4
4 changed files with 30 additions and 2 deletions
|
|
@ -453,3 +453,26 @@ def run_doctest(module, verbosity=None):
|
|||
if verbose:
|
||||
print 'doctest (%s) ... %d tests with zero failures' % (module.__name__, t)
|
||||
return f, t
|
||||
|
||||
#=======================================================================
|
||||
# Threading support to prevent reporting refleaks when running regrtest.py -R
|
||||
|
||||
def threading_setup():
|
||||
import threading
|
||||
return len(threading._active), len(threading._limbo)
|
||||
|
||||
def threading_cleanup(num_active, num_limbo):
|
||||
import threading
|
||||
import time
|
||||
|
||||
_MAX_COUNT = 10
|
||||
count = 0
|
||||
while len(threading._active) != num_active and count < _MAX_COUNT:
|
||||
count += 1
|
||||
time.sleep(0.1)
|
||||
|
||||
count = 0
|
||||
while len(threading._limbo) != num_limbo and count < _MAX_COUNT:
|
||||
count += 1
|
||||
time.sleep(0.1)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue