[issue37387] test_compileall fails randomly on Windows when tests are run in parallel

STINNER Victor report at bugs.python.org
Fri Apr 30 08:03:50 EDT 2021


STINNER Victor <vstinner at python.org> added the comment:

I proposed a way to fix the issue:

"Maybe the test should copy all .py files of the stdlib into a temporary directory and work there, to not impact other tests run in parallel."


Shreyan Avigyan:
> Though I've never been able to reproduce this test failure. Maybe it's fixed (maybe it was a side effect of another test)?

It's a race condition. It's hard to reproduce in a reliable way, but I'm sure that it has not been fixed.

The bug happens when one process tries to recreate the .pyc, whereas another process has the old .pyc file open. You can maybe make the issue more likely by adding a sleep in the code reading pyc content.

For example, in the FileLoader.get_data() method of importlib._bootstrap_external. Hacking importlib is non trivial, since the Python code is compiled as a frozen module.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37387>
_______________________________________


More information about the Python-bugs-list mailing list