eryksun added the comment:

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.

----------
nosy: +eryksun

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue4944>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to