diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-04-20 11:40:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-20 11:40:08 (GMT) |
commit | d20324a7fab6734bae19b1f070b5c8aae5ff3612 (patch) | |
tree | 4f14e79dd66ec723bb7b2d9371860cb30215a703 /Lib/test/support/__init__.py | |
parent | b85c136903c6d2368162f7c4a58f258c9c69ead0 (diff) | |
download | cpython-d20324a7fab6734bae19b1f070b5c8aae5ff3612.zip cpython-d20324a7fab6734bae19b1f070b5c8aae5ff3612.tar.gz cpython-d20324a7fab6734bae19b1f070b5c8aae5ff3612.tar.bz2 |
support.threading_cleanup() log a warning on fail (#1195)
The @reap_threads decorator and the threading_cleanup() function of
test.support now log a warning if they fail to clenaup threads.
Fix also the usage of support.threading_cleanup() in
test_urllib2_localnet.
The log may help to debug such other warning seen on the AMD64
FreeBSD CURRENT Non-Debug 3.x buildbot:
Warning -- threading._dangling was modified by test_logging
Diffstat (limited to 'Lib/test/support/__init__.py')
-rw-r--r-- | Lib/test/support/__init__.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 21d8f2c..d3beef2 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -2019,13 +2019,20 @@ def threading_cleanup(*original_values): if not _thread: return _MAX_COUNT = 100 + t0 = time.monotonic() for count in range(_MAX_COUNT): values = _thread._count(), threading._dangling if values == original_values: break time.sleep(0.01) gc_collect() - # XXX print a warning in case of failure? + else: + dt = time.monotonic() - t0 + print("Warning -- threading_cleanup() failed to cleanup %s threads " + "after %.0f sec (count: %s, dangling: %s)" + % (values[0] - original_values[0], dt, + values[0], len(values[1])), + file=sys.stderr) def reap_threads(func): """Use this function when threads are being used. This will |