-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Description
Bug report
Bug description:
Hello,
By pure chance, I have found the following, which I consider as a bug for reasons that will appear in the description of said bug.
Suppose we have the following python modules:
foomodule.py:
import threading
msg = "hello from foo"
from barmodule import baz
t = threading.Thread(target=baz)
t.start()
t.join()
barmodule.py
def baz():
import foomodule
print('baz', foomodule.msg)
If we run this code with the command python foomodule.py
, the program hangs forever. However, a normal python user would probably expect this to not happen as the thread is in principle meant to run in parallel of the code following the t.start()
call.
I do know that the lock on which it is waiting is used to protect the import system from race conditions, but the point is that this deadlock is not detected and the user gets no error message or warning telling them they may have done something wrong (in this case a circular import through multiple threads), which is why I consider this as a bug.
Hope someone reviews this bug report and can fix this issue.
Regards,
Jerem2360.
CPython versions tested on:
3.12
Operating systems tested on:
Windows