asyncio.asyncio.subprocess.Process.communicate()

coroutine communicate(input=None)

Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be data to be sent to the child process, or None, if no data should be sent to the child. The type of input must be bytes.

communicate() returns a tuple (stdout_data, stderr_data).

If a BrokenPipeError or ConnectionResetError exception is raised when writing input into stdin, the exception is ignored. It occurs when the process exits before all data are written into stdin.

Note that if you want to send data to the process’s stdin, you need to create the Process object with stdin=PIPE. Similarly, to get anything other than None in the result tuple, you need to give stdout=PIPE and/or stderr=PIPE too.

This method is a coroutine.

Note

The data read is buffered in memory, so do not use this method if the data size is large or unlimited.

Changed in version 3.4.2: The method now ignores BrokenPipeError and ConnectionResetError.

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

Please login to continue.