Python's threading
documentation states:
Other than in the main module, an import should not have the side effect of spawning a new thread and then waiting for that thread in any way. Failing to abide by this restriction can lead to a deadlock if the spawned thread directly or indirectly attempts to import a module.
I'm looking for example code that demonstrates this restriction.
I tried this, a module that spawns a thread whose target tries to import
sys
:When the python interpreter is launched and an attempt to import the module above is made, it indeed freezes.