Gregory P. Smith <g...@krypto.org> added the comment:

threading locks cannot be used to protect things outside of a single process.  
Any code using them to do that is broken.

In your examples you are suggesting a class that wants to do one or more mysql 
actions within a destructor and worried that the __del__ method would be called 
in the fork()'ed child process.

With the subprocess module, this will never happen.  the child exec's or does a 
hard exit.   
http://hg.python.org/cpython/file/bd2c2def77a7/Modules/_posixsubprocess.c#l634

When someone is using os.fork() directly, they are responsible for all 
destructors in their application behaving sanely within the child process.

Destructors are an evil place to put code that does actual work and are best 
avoided.  When required, they must be written defensively because they really 
cannot depend on much of the Python execution environment around them being in 
a functional state as they have no control over _when_ they will be called 
during shutdown.  Nothing new here.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue6721>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to