Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
This repository was archived by the owner on Nov 23, 2017. It is now read-only.

`loop.subprocess_shell() and loop.subprocess_exec() may block #414

Open
@Martiusweb

Description

@Martiusweb

Hi,

Subprocess creation is handled by loop.subprocess_exec() and loop.subprocess_shell(). Both uses subprocess.Popen(), but the later performs at least one blocking read on a pipe (on unix at least), used to detect the outcome of exec() in the new child process (see: https://github.com/python/cpython/blob/master/Lib/subprocess.py#L1538).

This cause the loop to block if the fork/exec takes time in the subprocess, for instance because the system is under high IO pressure, or if preexec_fn is doing a slow operation.

I am not sure of how this issue should be fixed.
There is a quick-and-dirty fix : invoke subprocess.Popen() in an executor thread, but we probably want to address the original issue (the blocking read).
In this later case, can we update subprocess.Popen() or should we try to subclass it in asyncio without modifying cpython?

I can try to work on a patch, but suggestions are more than welcome about where to start (especially my previous question !).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions