homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author chris.jerdonek
Recipients brett.cannon, chris.jerdonek, ezio.melotti, zach.ware
Date 2013年01月26日.17:22:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1359220968.86.0.354478530217.issue16968@psf.upfronthosting.co.za>
In-reply-to
Content
Okay, I think I understand the issue better now. The threading._dangling warning happens because when leaving the saved_test_environment context manager in regrtest:
http://hg.python.org/cpython/file/fcdb35b114ab/Lib/test/regrtest.py#l1271
the context manager finds threads still in threading._dangling that weren't there at the beginning. I think the threads are still in there because the "tests" variable in the code linked to above is holding references to those threads (which isn't surprising given what test_concurrent_futures.py tests). So this is preventing the threads (which are in a WeakSet) from being garbage collected.
On my machine, severing those references before leaving the context manager solves the problem. You can do this by adding "test = 0" after the test_runner() line, or defining "tests" inside an inner function as follows:
if test_runner is None:
 def test_runner():
 tests = unittest.TestLoader().loadTestsFromModule(the_module)
 support.run_unittest(tests)
test_runner()
To be completely sure, we may also need to do something to ensure that the threads are garbage collected before leaving the context manager. Currently, an explicit call to support.gc_collect() happens in threading_cleanup() (which is in turn called by reap_threads(), etc):
http://hg.python.org/cpython/file/fcdb35b114ab/Lib/test/support.py#l1665
But I'm not sure if that's late enough in the process to guarantee garbage collection of those threads with the test_runner() change above (since the tests list might still be defined).
History
Date User Action Args
2013年01月26日 17:22:48chris.jerdoneksetrecipients: + chris.jerdonek, brett.cannon, ezio.melotti, zach.ware
2013年01月26日 17:22:48chris.jerdoneksetmessageid: <1359220968.86.0.354478530217.issue16968@psf.upfronthosting.co.za>
2013年01月26日 17:22:48chris.jerdoneklinkissue16968 messages
2013年01月26日 17:22:48chris.jerdonekcreate

AltStyle によって変換されたページ (->オリジナル) /