summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_support.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-05-14 22:40:34 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-05-14 22:40:34 (GMT)
commit0db3cd6700d18f3bfcaf71405d5da43c1928d55e (patch)
treee24f9f80510789cd38cd5f788382f4b1dc4a0666 /Lib/test/test_support.py
parent92d102bf6d90e015360f71c370b540151b4acdba (diff)
downloadcpython-0db3cd6700d18f3bfcaf71405d5da43c1928d55e.zip
cpython-0db3cd6700d18f3bfcaf71405d5da43c1928d55e.tar.gz
cpython-0db3cd6700d18f3bfcaf71405d5da43c1928d55e.tar.bz2
a useful decorator for cleaning up threads
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r--Lib/test/test_support.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index 7d0ec8d..52dd16e 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -5,6 +5,7 @@ if __name__ != 'test.test_support':
import contextlib
import errno
+import functools
import socket
import sys
import os
@@ -934,6 +935,16 @@ def threading_cleanup(num_active, num_limbo):
count += 1
time.sleep(0.1)
+def reap_threads(func):
+ @functools.wraps(func)
+ def decorator(*args):
+ key = threading_setup()
+ try:
+ return func(*args)
+ finally:
+ threading_cleanup(*key)
+ return decorator
+
def reap_children():
"""Use this function at the end of test_main() whenever sub-processes
are started. This will help ensure that no extra children (zombies)