[issue30891] Sometimes, test_concurrency() of test_import fails with AttributeError: module 'package' has no attribute 'submodule' on AMD64 Windows8.1 Refleaks 3.6

STINNER Victor report at bugs.python.org
Mon Jul 10 11:09:27 EDT 2017


STINNER Victor added the comment:

Using attached importlib_sleep.patch, you can *see* the race condition with:

diff --git a/Lib/test/test_import/data/package/__init__.py b/Lib/test/test_import/data/package/__init__.py
index a4f2bc3..f07eb11 100644
--- a/Lib/test/test_import/data/package/__init__.py
+++ b/Lib/test/test_import/data/package/__init__.py
@@ -1,2 +1,3 @@
 import package.submodule
+print("package: id=%#x" % id(package))
 package.submodule


Example of output:
---
haypo at selma$ ./python -m test -m test_concurrency -v test_import
package: id=0x7fb497400d58
package: id=0x7fb49744d458
test test_import failed -- (...)
---

Lib/test/test_import/data/package/__init__.py is run twice instead of being run once. A lock is missing somewhere on the package module.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30891>
_______________________________________


More information about the Python-bugs-list mailing list