diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-08-28 00:24:52 +0200 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-08-28 00:24:52 +0200 |
commit | f7a8e9cf051e4ab9412f276596428fe414ac0ce6 (patch) | |
tree | 95f56329cf9e8b3ea3e8030e9d4e0e99c5a86e99 /Lib/test/test_threaded_import.py | |
parent | 57ba391a17c2c1f4f6d028ac23ea286248d6a196 (diff) | |
download | cpython-f7a8e9cf051e4ab9412f276596428fe414ac0ce6.tar.gz |
Issue #15781: Fix two small race conditions in import's module locking.
Diffstat (limited to 'Lib/test/test_threaded_import.py')
-rw-r--r-- | Lib/test/test_threaded_import.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_threaded_import.py b/Lib/test/test_threaded_import.py index f540bdc67c..cfc6842e1f 100644 --- a/Lib/test/test_threaded_import.py +++ b/Lib/test/test_threaded_import.py @@ -224,7 +224,17 @@ class ThreadedImportTests(unittest.TestCase): @reap_threads def test_main(): - run_unittest(ThreadedImportTests) + old_switchinterval = None + try: + old_switchinterval = sys.getswitchinterval() + sys.setswitchinterval(0.00000001) + except AttributeError: + pass + try: + run_unittest(ThreadedImportTests) + finally: + if old_switchinterval is not None: + sys.setswitchinterval(old_switchinterval) if __name__ == "__main__": test_main() |