[Python-Dev] Best Python API for exposing posix_spawn

Random832 random832 at fastmail.com
Mon Jan 8 19:00:32 EST 2018


On Mon, Jan 8, 2018, at 18:05, Gregory P. Smith wrote:
> i agree with just a list of tuples, but i suggest creating namedtuple
> instances in the posix module for the purpose (one each for close, dup2,
> open) .  Don't put a reference to a function in the tuple as Serhiy
> suggested as, while obvious what it means, it gives the wrong impression to
> the user: nothing is calling the Python functions.  This is a posix API
> that takes a list of arguments for a specific set of system calls for _it_
> to make for us in a specific order.

Instead of a sequence of functions to call, it'd be nice if a higher-level API could allow just passing in a mapping of file descriptor numbers to what they should point to in the new process, and the implementation figures out what sequence is necessary to get that result.

And at that point we could just extend the subprocess API to allow redirection of file descriptors other than 0/1/2, and have an implementation of it in terms of posix_spawn.


More information about the Python-Dev mailing list