summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_threaded_import.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_threaded_import.py')
-rw-r--r--Lib/test/test_threaded_import.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/Lib/test/test_threaded_import.py b/Lib/test/test_threaded_import.py
index dc27d4e..0642d25 100644
--- a/Lib/test/test_threaded_import.py
+++ b/Lib/test/test_threaded_import.py
@@ -6,7 +6,7 @@
# randrange, and then Python hangs.
import thread
-from test.test_support import verbose, TestSkipped
+from test.test_support import verbose, TestSkipped, TestFailed
critical_section = thread.allocate_lock()
done = thread.allocate_lock()
@@ -25,6 +25,23 @@ def task():
if finished:
done.release()
+def test_import_hangers():
+ import sys
+ if verbose:
+ print "testing import hangers ...",
+
+ from test import threaded_import_hangers
+
+ try:
+ if threaded_import_hangers.errors:
+ raise TestFailed(threaded_import_hangers.errors)
+ elif verbose:
+ print "OK."
+ finally:
+ # In case this test is run again, make sure the helper module
+ # gets loaded from scratch again.
+ del sys.modules['test.threaded_import_hangers']
+
# Tricky: When regrtest imports this module, the thread running regrtest
# grabs the import lock and won't let go of it until this module returns.
# All other threads attempting an import hang for the duration. Since
@@ -53,5 +70,7 @@ def test_main(): # magic name! see above
print "OK."
done.release()
+ test_import_hangers()
+
if __name__ == "__main__":
test_main()