Author martius
Recipients gvanrossum, martius, vstinner, yselivanov
Date 2015-02-27.18:11:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I would like to add a detach() method to base_suprocess.BaseSuprocessTransport, which would release the underlying Popen object to the user, pretty much like socket.detach() detaches a socket object and returns the fd.

The rationale is the following: the lifetime of a subprocess started using a loop is bound to that loop, or require to clause the loop without terminating the process which leads to resource leaks (the stdin/stdout pipes can't be closed).

It may be useful in some cases. For instance, I create a fork of a process running a loop which started one or more subprocesses. In the child processus, I'd like to close the pipes and free the transport objects by calling:

    proc = transport.detach()


The process is still running, in the parent process, everything looks like before the fork, the child can forget about the parent loop without fearing resource leaks.

It is somewhat related to (Support fork).

I propose a patch which adds BaseSubprocessTransport.detach(), a specialized version for _UnixSubprocessTransport taking care of removing the callbacks from the ChildWatcher and a detach method for the pipes transports for unix and proactor.
Date User Action Args
2015-02-27 18:11:10martiussetrecipients: + martius, gvanrossum, vstinner, yselivanov
2015-02-27 18:11:10martiussetmessageid: <>
2015-02-27 18:11:10martiuslinkissue23540 messages
2015-02-27 18:11:09martiuscreate