Skip to content

should we be more aggressive about reaping child processes? #879

@njsmith

Description

@njsmith

Right now, I believe that we don't reap child processes until the user calls .wait or .poll. (or, if that never happens, then until the backstop code in subprocess starts trying to reap old processes when a new one is spawned.)

Of course on Windows this is fine because zombies aren't a thing. But maybe we should reap more aggressively on posix? If we were using SIGCHLD like most async libraries do, then we'd be reaping processes as soon as they exit.

E.g. on Linux, maybe the wait logic should be something like:

def _thread_wait(token, process):
    process._popen.wait()
    token.call_soon_threadsafe(process._waited.set()

?

(Note that Popen.wait is thread-safe, so this is legal: https://bugs.python.org/issue21291)

CC: @oremanj

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions