[Python-Dev] Proposal for a new function "open_noinherit" to avoid problems with subprocesses and security risks

Henning von Bargen henning.vonbargen at arcor.de
Sat Jun 23 19:01:45 CEST 2007


thank you for speaking it out loud on python-dev.
And you know better english words like "tremendous"
and "obtuse" (whatever that means:-)
that express what a PITA this really is.

When I said it took me two weeks, that's actually not the truth.
It was even more.
The first problem was with RotatingLogHandler, and just like you,
I first thought it was a threading problem.
Thus I wrote my own version of RotationLogHandler, which
builds new log file name with a timestamp instead of
renaming the old log files.

Actually, the point when I found out that indeed subprocesses
were causing problems was when I had the program running on
about 50 computers (for different clients) and for some clients
the program would run very well, while for other clients there
were often errors - suddenly it came to my mind that the clients
with the errors were those who used a subprocess for sending
e-mail via MAPI, whereas the clients who didn't experience
problems were those who used smtplib for sending e-mail
(no subprocesses).
And then it took me a few days to write my replacement open
function and to replace each occurence of "open" with the
replacement function.
And then, another few days later, a client told me that the errors
*still* occured (although in rare cases).
At first I built a lot of tracing and debugging into the MAPI subprocess
Finally I found out that it was actually shutil.filecopy that caused the 
Of course, I hadn't searched for "open" in the whole bunch of standard


More information about the Python-Dev mailing list