possible to preserve subprocess.Popen objects for later?

Diez B. Roggisch deets at nospam.web.de
Thu Jun 21 19:24:47 EDT 2007


Ratko schrieb:
> Hi all,
> 
> I have a python gui app that launches multiple applications using
> subprocess.Popen class and prints their output in the gui (using
> PIPEs, threads and wxPython). Everything works great but the problem
> is that some applications should run in the background (ie they don't
> close when the gui closes) so next time when you start the gui it will
> not have a handle on those processes that are still running and
> therefore won't be able to print their output.
> 
> So, I was wondering if there is any way to "preserve" the Popen object
> of those background processes and reload them when the gui is
> restarted? Ideally I would like to have the whole Popen object
> preserved but I could also get by with just the Popen.stdout file
> object. I can save the Popen.stdout.fileno() integer because that's
> what I use in os.read() to read the output anyway but that doesn't
> work.
> 
> I have doubts that this could even conceptually work but I thought I'd
> try asking anyway. I don't have a full understanding of how processes
> and pipes work on the system level...

This doesn't work. What could work is that you create a python spawning 
process that lives as long as all it's popened childrend - and then let 
the gui connect to that, by whatever IPC means you like. E.g. pyro.

Diez



More information about the Python-list mailing list