asyncio.AbstractEventLoop.subprocess_exec()

coroutine AbstractEventLoop.subprocess_exec(protocol_factory, *args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)

Create a subprocess from one or more string arguments (character strings or bytes strings encoded to the filesystem encoding), where the first string specifies the program to execute, and the remaining strings specify the program’s arguments. (Thus, together the string arguments form the sys.argv value of the program, assuming it is a Python script.) This is similar to the standard library subprocess.Popen class called with shell=False and the list of strings passed as the first argument; however, where Popen takes a single argument which is list of strings, subprocess_exec() takes multiple string arguments.

The protocol_factory must instanciate a subclass of the asyncio.SubprocessProtocol class.

Other parameters:

  • stdin: Either a file-like object representing the pipe to be connected to the subprocess’s standard input stream using connect_write_pipe(), or the constant subprocess.PIPE (the default). By default a new pipe will be created and connected.
  • stdout: Either a file-like object representing the pipe to be connected to the subprocess’s standard output stream using connect_read_pipe(), or the constant subprocess.PIPE (the default). By default a new pipe will be created and connected.
  • stderr: Either a file-like object representing the pipe to be connected to the subprocess’s standard error stream using connect_read_pipe(), or one of the constants subprocess.PIPE (the default) or subprocess.STDOUT. By default a new pipe will be created and connected. When subprocess.STDOUT is specified, the subprocess’s standard error stream will be connected to the same pipe as the standard output stream.
  • All other keyword arguments are passed to subprocess.Popen without interpretation, except for bufsize, universal_newlines and shell, which should not be specified at all.

Returns a pair of (transport, protocol), where transport is an instance of BaseSubprocessTransport.

This method is a coroutine.

See the constructor of the subprocess.Popen class for parameters.

doc_python
2016-10-07 17:26:35
Comments
Leave a Comment

Please login to continue.