subprocess.Popen zombie
Robin Becker
robin at reportlab.com
Wed May 20 12:44:50 EDT 2015
On 20/05/2015 16:42, Alain Ketterlin wrote:
> Robin Becker <robin at reportlab.com> writes:
.............
>> The code I used to use with os.spawnl was even worse in leaving
>> zombies around.
>
> For the same reason (os.wait() and os.waitpid() let you ... wait for
> child-processes).
>
>> I suppose I needed to keep a record of all the pid's and wait on them
>> at some convenient time.
>
> Yes.
>
>> The subprocess version appears to be doing that for me somehow.
>
> Not sure what you mean. You have to do the bookkeeping yourself.
It seems there is some notion of book keeping in subprocess.py
Popen instances have a __del__ method which records un-norwegian live instances
in a module global _active
if self.returncode is None and _active is not None:
# Child is still running, keep us alive until we can wait on it.
_active.append(self)
when another Popen is created there's a call to _cleanup which processes that
list and reaps those that can be raptured.
>
> (But, does beep really take so much time that you can't just call() it?)
>
not really, it's just normal to keep event routines short; the routine which
beeps is after detection of the cat's entrance into the house and various
recognition schemes have pronounced intruder :)
Probably should all have gone into a separate thread, but I dislike threaded
code and I would probably get into trouble with the PyQT event loop.
> -- Alain.
>
--
Robin Becker
More information about the Python-list
mailing list