[Python-checkins] r47013 - in python/trunk: Lib/test/test_socket.py Lib/test/test_support.py Lib/test/test_threadedtempfile.py Misc/build.sh
Neal Norwitz
nnorwitz at gmail.com
Sun Jun 18 21:39:26 CEST 2006
I should note that 10 is arbitrary. This waits a total of a second.
That may not be enough time.
On 6/18/06, neal.norwitz <python-checkins at python.org> wrote:
> Author: neal.norwitz
> Date: Sun Jun 18 21:35:01 2006
> New Revision: 47013
>> Modified:
> python/trunk/Lib/test/test_socket.py
> python/trunk/Lib/test/test_support.py
> python/trunk/Lib/test/test_threadedtempfile.py
> python/trunk/Misc/build.sh
> Log:
> 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.
>>> Modified: python/trunk/Lib/test/test_socket.py
> ==============================================================================
> --- python/trunk/Lib/test/test_socket.py (original)
> +++ python/trunk/Lib/test/test_socket.py Sun Jun 18 21:35:01 2006
> @@ -906,7 +906,10 @@
> tests.append(BasicSocketPairTest)
> if sys.platform == 'linux2':
> tests.append(TestLinuxAbstractNamespace)
> +
> + thread_info = test_support.threading_setup()
> test_support.run_unittest(*tests)
> + test_support.threading_cleanup(*thread_info)
>> if __name__ == "__main__":
> test_main()
>> Modified: python/trunk/Lib/test/test_support.py
> ==============================================================================
> --- python/trunk/Lib/test/test_support.py (original)
> +++ python/trunk/Lib/test/test_support.py Sun Jun 18 21:35:01 2006
> @@ -453,3 +453,26 @@
> 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)
> +
>> Modified: python/trunk/Lib/test/test_threadedtempfile.py
> ==============================================================================
> --- python/trunk/Lib/test/test_threadedtempfile.py (original)
> +++ python/trunk/Lib/test/test_threadedtempfile.py Sun Jun 18 21:35:01 2006
> @@ -22,7 +22,7 @@
>> import thread # If this fails, we can't test this module
> import threading
> -from test.test_support import TestFailed
> +from test.test_support import TestFailed, threading_setup, threading_cleanup
> import StringIO
> from traceback import print_exc
> import tempfile
> @@ -48,6 +48,7 @@
>> def test_main():
> threads = []
> + thread_info = threading_setup()
>> print "Creating"
> for i in range(NUM_THREADS):
> @@ -72,6 +73,7 @@
> if errors:
> raise TestFailed(msg)
>> + threading_cleanup(*thread_info)
>> if __name__ == "__main__":
> import sys, getopt
>> Modified: python/trunk/Misc/build.sh
> ==============================================================================
> --- python/trunk/Misc/build.sh (original)
> +++ python/trunk/Misc/build.sh Sun Jun 18 21:35:01 2006
> @@ -60,7 +60,7 @@
> # Note: test_XXX (none currently) really leak, but are disabled
> # so we don't send spam. Any test which really leaks should only
> # be listed here if there are also test cases under Lib/test/leakers.
> -LEAKY_TESTS="test_(ctypes|filecmp|socket|threadedtempfile|threading|urllib2)"
> +LEAKY_TESTS="test_(XXX)" # Currently no tests should report spurious leaks.
>> # Skip these tests altogether when looking for leaks. These tests
> # do not need to be stored above in LEAKY_TESTS too.
> _______________________________________________
> Python-checkins mailing list
> Python-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-checkins
>
More information about the Python-checkins
mailing list