No threading.start_new_thread(), useful addition?
Ethan Furman
ethan at stoneleaf.us
Fri Oct 9 18:57:52 EDT 2009
Christian Heimes wrote:
> 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
Okay, I for one will never start threads as a side-effect of module import.
Other than that, are there other inherent problems with using that
decorator at non-import times?
~Ethan~
More information about the Python-list
mailing list