[issue31447] proc communicate not exiting on python subprocess timeout using PIPES

2017-09-18 Thread Leonardo Francalanci
Leonardo Francalanci added the comment: That works! But when I said "also with close_fds=True", I meant that I tried WITHOUT overriding stdin, stdout, and stderr AND setting close_fds=True, but it didn't work. What worked was not overriding stdin/out/err and adding os.set_inheritabl

[issue31447] proc communicate not exiting on python subprocess timeout using PIPES

2017-09-15 Thread Leonardo Francalanci
Leonardo Francalanci added the comment: can I at least change the call to: subprocess.run('cmd /S /C waitfor g /t 200', shell=False, timeout=4) in any way to avoid the problem? I tried with stdin=subprocess.DEVNULL,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL; also with close_fds=True

[issue31447] proc communicate not exiting on python subprocess timeout using PIPES

2017-09-15 Thread Leonardo Francalanci
Leonardo Francalanci added the comment: I'm really sorry, you are 100% correct: it blocks on the pipe (my tests killed the process tree before reading from the pipes). Still, I think there should be a way to actually read the output also in this case... works for me when I kill the whole

[issue31447] proc communicate not exiting on python subprocess timeout using PIPES

2017-09-14 Thread Leonardo Francalanci
Leonardo Francalanci added the comment: I have a workaround, and I guess this means there's a bug in the current implementation of stdout/stderr=subprocess.PIPE; if I open my own pipes instead of using subprocess.PIPE everything seems to work (provided I close the pipe before reading from

[issue31447] proc communicate not exiting on python subprocess timeout using PIPES

2017-09-13 Thread Leonardo Francalanci
Leonardo Francalanci added the comment: (forgot: Issue 26534 is about shell=True, I use shell=False, right?) -- ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/i

[issue31447] proc communicate not exiting on python subprocess timeout using PIPES

2017-09-13 Thread Leonardo Francalanci
Leonardo Francalanci added the comment: thank you for your replies! I used waitfor because it's the simplest and shortest way to have reproducible code. The issue I'm having is obviously not with waitfor, but with another exe, but this doesn't change the fact that I need a way to exit as soon

[issue31447] proc communicate not exiting on python subprocess timeout using PIPES

2017-09-13 Thread Leonardo Francalanci
Leonardo Francalanci added the comment: The called "C:\\Program Files (x86)\\Anaconda3\\Python.exe" process exits after 4 seconds. The reason why it ends shouldn't matter, right? I expect that a call to communicate should exit as soon as the called process is not running anymore. I

[issue31447] proc communicate not exiting on python subprocess timeout using PIPES

2017-09-13 Thread Leonardo Francalanci
Changes by Leonardo Francalanci <ultimoam...@gmail.com>: -- components: +Interpreter Core type: -> behavior ___ Python tracker <rep...@bugs.python.org> <https://bugs.pyt

[issue31447] proc communicate not exiting on python subprocess timeout using PIPES

2017-09-13 Thread Leonardo Francalanci
New submission from Leonardo Francalanci: the script below (a python process is called, which calls a waitfor cmd with a timeout of 4 seconds) is supposed to end after 4 seconds. But instead proc.communicate stops after the 20 seconds timeout. Everything works 100% ok if I remove the stdin