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 lesha
Recipients Giovanni.Bajo, avian, bobbyi, gregory.p.smith, jcea, lesha, neologix, nirai, pitrou, sbt, sdaoden, vinay.sajip, vstinner
Date 2012-06-01.00:25:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> I think forkall() on Solaris acts like that, but the normal fork() 
> function does not.  Only the thread which performs fork() will survive 
> in the child process.

Sorry, brain fail. A slightly more contrived failure case is this:

  preexec_fn=lambda: conn.doWork()

Everything else is the same.

Another failure case is:

  class MySQLConn:
    ... doWork as before ...

    def __del__(self):

Followed by:

  def thread3(conn):
    while True:['nonexistent_program']) 

The destructor will fire in the child and corrupt the parent's data.

An analogous example is:

  conn = MySQLConn()
  while True:
    if os.fork() == 0:  # child
      raise Exception('doom')  # triggers destructor

Basically, it is really really dangerous to release locks that protect any resources that are not copied by fork (i.e. network resources, files, DB connections, etc, etc).
Date User Action Args
2012-06-01 00:25:02leshasetrecipients: + lesha, gregory.p.smith, vinay.sajip, jcea, pitrou, vstinner, nirai, bobbyi, neologix, Giovanni.Bajo, sdaoden, sbt, avian
2012-06-01 00:25:02leshasetmessageid: <>
2012-06-01 00:25:01leshalinkissue6721 messages
2012-06-01 00:25:01leshacreate