Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8779787

Browse files
committed
Workaround by Tim Peters to skip this test if run from test.autotest,
in which case it will hang because the import lock is already held by the main thread.
1 parent bf77c46 commit 8779787

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Lib/test/test_threaded_import.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# randrange, and then Python hangs.
77

88
import thread
9-
from test_support import verbose
9+
from test_support import verbose, TestSkipped
1010

1111
critical_section = thread.allocate_lock()
1212
done = thread.allocate_lock()
@@ -32,6 +32,10 @@ def task():
3232

3333
def test_main(): # magic name! see above
3434
global N, done
35+
import sys
36+
for modname in sys.modules:
37+
if modname.find('autotest') >= 0:
38+
raise TestSkipped("can't run from autotest")
3539
done.acquire()
3640
for N in (20, 50) * 3:
3741
if verbose:

0 commit comments

Comments
 (0)