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 ncoghlan
Recipients Alex.Roitman, barry, brett.cannon, eric.araujo, gregory.p.smith, ncoghlan, r.david.murray
Date 2010-08-17.20:56:13
SpamBayes Score 2.1437387e-08
Marked as misclassified No
Message-id <1282078575.39.0.152672536072.issue9573@psf.upfronthosting.co.za>
In-reply-to
Content
It turns out my proposed patch is incorrect anyway - it will do the wrong thing if a thread *other* than the one doing the fork is in the middle of a nested import at the time the fork occurs.

With issue 7242 establishing that the current thread ID may not survive the forking process on all platforms, the only way I can see to get completely correct semantics for the fork-as-a-side-effect of import case is to give the forking thread another way to detect "did I own the import lock before the fork?". One way to do that would be to move the lock nesting count into thread local storage, although that would likely suffer cross-platform incompatibility fun and games as well.

Given that, I'm inclined to go with what Brett said: don't do that. Use a __name__ == "__main__" guard so the fork only happens when run as a script, not when imported.
History
Date User Action Args
2010-08-17 20:56:15ncoghlansetrecipients: + ncoghlan, barry, brett.cannon, gregory.p.smith, eric.araujo, r.david.murray, Alex.Roitman
2010-08-17 20:56:15ncoghlansetmessageid: <1282078575.39.0.152672536072.issue9573@psf.upfronthosting.co.za>
2010-08-17 20:56:14ncoghlanlinkissue9573 messages
2010-08-17 20:56:13ncoghlancreate