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 eryksun
Recipients Emil.Styrke, amaury.forgeotdarc, brian.curtin, eckhardt, eryksun, ggenellina, javen72, terry.reedy
Date 2015-03-27.04:15:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1427429718.39.0.708168334628.issue4944@psf.upfronthosting.co.za>
In-reply-to
Content
Emil,

Your example child process opens the file with only read sharing, which fails with a sharing violation if some other process inherits the file handle with write access. The `with` block only prevents this in a single-threaded environment. When you spawn 10 children, each from a separate thread, there's a good chance that one child will inherit a handle that triggers a sharing violation in another child.

Using close_fds is a blunt solution since it prevents inheriting all inheritable handles. What you really need here has actually already been done for you. Just use the file descriptor that mkstemp returns, i.e. use os.fdopen(infd, 'wb'). mkstemp opens the file with O_NOINHERIT set in the flags.
History
Date User Action Args
2015-03-27 04:15:18eryksunsetrecipients: + eryksun, terry.reedy, amaury.forgeotdarc, ggenellina, eckhardt, javen72, brian.curtin, Emil.Styrke
2015-03-27 04:15:18eryksunsetmessageid: <1427429718.39.0.708168334628.issue4944@psf.upfronthosting.co.za>
2015-03-27 04:15:18eryksunlinkissue4944 messages
2015-03-27 04:15:17eryksuncreate