On 30-03-2005 16:13, "Adam R. B. Jack" <[EMAIL PROTECTED]> wrote:
>> Motivation:
>> 1) the "subprocess" module described in PEP 324 finally properly solves
>> running processes within python using a decent interface. It's new in
> python
>> 2.4. Needless to say, we run a lot of subprocesses!
> 
> Good find, looks nice. It does seem to have the abilities I've been seeking,
> including passing environments in a thread safe manner.
> 
> I suspect, however, we'd still want to (on posix) set the process group
> leadership prior to invoking the subprocess, and later (if needed) killing
> the process group.

+1

> [Almost seemed we could use the preexec_fn to do this,
> but I suspect we'd still need to fork (to get the child pid/group id).] This
> won't be available to us on Windows, but then we are no worse off than
> today.

Apparently you can do all that kind of stuff through the win32 api, and that
is pretty well-covered in python. Would just have to learn how. I have no
inclination whatsoever to learn the windows programming model though!

> Maybe we'll pickup some (small) mileage from being able to close the
> processes stdout/stderr. I assume we'd close stdin from the start.

I really really recommend reading through the subprocess module's source
code. It does all this kind of stuff rather nicely (if you don't specify
you'll be reading from stdin, its closed, if you lose track of the
subprocess object, it gets garbage collected and closed). All very
educational (for me at least). And presumably a lot more efficient than
firing up shells and writing temporary files for lots of commands ;)

I suspect in the end it won't be enough for us when we invoke the truly
untrusted processes (haven't figured out how to hook group management into
it, for example), but I'm just learning about all this atm.


Cheers,


Leo



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to