Message294066
Seeing EINVAL here while the child process is alive could mean the read end of the pipe was closed. For example:
>>> import time, subprocess
>>> cmd = 'python -c "import os, time; os.close(0); time.sleep(15)"'
>>> p = subprocess.Popen(cmd, stdin=subprocess.PIPE, bufsize=0)
>>> time.sleep(5); p.communicate(b'spam')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python36\lib\subprocess.py", line 821, in communicate
self._stdin_write(input)
File "C:\Program Files\Python36\lib\subprocess.py", line 776, in _stdin_write
self.stdin.write(input)
OSError: [Errno 22] Invalid argument
If buffered, the error would instead occur at self.stdin.close(). Both cases are currently checked, but the error is only ignored when the child process is still alive.
The underlying Windows error is ERROR_NO_DATA. If we could know that for certain, then we could ignore it as a BrokenPipeError. Currently all we have to go on from _Py_write is the CRT's EINVAL errno value. In contrast, when creating an OSError from the Windows last error value, winerror_to_errno() maps ERROR_NO_DATA as EPIPE. |
|
Date |
User |
Action |
Args |
2017-05-21 02:00:22 | eryksun | set | recipients:
+ eryksun, paul.moore, vstinner, tim.golden, zach.ware, steve.dower |
2017-05-21 02:00:22 | eryksun | set | messageid: <1495332022.44.0.641336080565.issue30418@psf.upfronthosting.co.za> |
2017-05-21 02:00:22 | eryksun | link | issue30418 messages |
2017-05-21 02:00:21 | eryksun | create | |
|