This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gregory.p.smith
Recipients Giovanni.Bajo, avian, bobbyi, gregory.p.smith, jcea, lesha, neologix, nirai, pitrou, sbt, sdaoden, vinay.sajip, vstinner
Date 2012-06-01.01:26:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1338514016.43.0.891727016505.issue6721@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-06-01 01:26:56gregory.p.smithsetrecipients: + gregory.p.smith, vinay.sajip, jcea, pitrou, vstinner, nirai, bobbyi, neologix, Giovanni.Bajo, sdaoden, sbt, avian, lesha
2012-06-01 01:26:56gregory.p.smithsetmessageid: <1338514016.43.0.891727016505.issue6721@psf.upfronthosting.co.za>
2012-06-01 01:26:55gregory.p.smithlinkissue6721 messages
2012-06-01 01:26:55gregory.p.smithcreate