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 sbt
Recipients asksol, brandon-rhodes, catalin.iacob, christian.heimes, cool-RR, dholth, jnoller, mrmekon, ned.deily, neologix, numbernine, pitrou, rcoyner, sbt, vsekhar
Date 2012-10-24.12:10:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1351080639.74.0.640176009677.issue8713@psf.upfronthosting.co.za>
In-reply-to
Content
> A use case for not using fork() is when your parent process opens some 
> system resources of some sort (for example a listening TCP socket). The 
> child will then inherit those resources, which can have all kinds of 
> unforeseen and troublesome consequences (for example that listening TCP 
> socket will be left open in the child when it is closed in the parent, 
> and so trying to bind() to the same port again will fail).
>
> Generally, I think having an option for zero-sharing spawning of 
> processes would help code quality.

The patch as it stands still depends on fd inheritance, so you would need to use FD_CLOEXEC on your listening socket.  But yes, it should be possible to use the closefds feature of _posixsubprocess.


BTW, I also have working code (which passes the unittests) that starts a helper process at the beginning of the program and which will fork processes on behalf of the other processes.  This also solves the issue of unintended inheritance of resources (and the mixing of fork with threads) but is as fast as doing normal forks.
History
Date User Action Args
2012-10-24 12:10:39sbtsetrecipients: + sbt, pitrou, christian.heimes, ned.deily, jnoller, rcoyner, asksol, cool-RR, dholth, brandon-rhodes, neologix, catalin.iacob, numbernine, vsekhar, mrmekon
2012-10-24 12:10:39sbtsetmessageid: <1351080639.74.0.640176009677.issue8713@psf.upfronthosting.co.za>
2012-10-24 12:10:39sbtlinkissue8713 messages
2012-10-24 12:10:39sbtcreate