No threading.start_new_thread(), useful addition?

Christian Heimes lists at cheimes.de
Fri Oct 9 18:45:21 EDT 2009


Laszlo Nagy wrote:
> IMHO it is much cleaner to implement this as a decorator. Pro: 
> transparent passing of positional and keyword arguments, keeps function 
> documentation.

You are entitled to your opinion but I STRONGLY recommend against your
decorator. You MUST NOT start threads a a side effect of a module
import. It can lead to severe bugs and dead lock the entire interpreter.
I'm speaking as an experienced Python developer and a CPython core
developer. Please trust me in this. The interaction between the import
system, its global import lock and threads can and will lead to
surprising and hard to debug bugs. A well designed application loads its
modules first and then initializes its components explicitly. You don't
want to fire up threads randomly!

Christian



More information about the Python-list mailing list