import, functions, and threading
aahz at pythoncraft.com
Fri Mar 12 07:14:43 CET 2004
There were some posts recently discussing whether it's poor style to put
import statements inside functions. I recently got reminded that there's
one very good reason to avoid it: Python has an import lock that blocks
more than one thread from executing import statements. Putting import
statements inside functions that might be called in a threaded
environment is asking for deadlock trouble.
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"Do not taunt happy fun for loops. Do not change lists you are looping over."
--Remco Gerlich, comp.lang.python
More information about the Python-list