
Hi there, In this section of the docs: https://docs.python.org/3/library/subprocess.html#subprocess.Popen.communica... the example shows: proc = subprocess.Popen(...)try: outs, errs = proc.communicate(timeout=15)except TimeoutExpired: proc.kill() outs, errs = proc.communicate() should it instead say: proc = subprocess.Popen(...)try: outs, errs = proc.communicate(timeout=15)except TimeoutExpired: proc.kill() thanks! - Oren

Hello! This is intentional. As the paragraph before the example says:
The child process is not killed if the timeout expires, so in order to cleanup properly a well-behaved application should kill the child process and finish communication
The kill() sends a signal that asks the process to exit, and the extra communicate waits until it actually exits. On 2/23/24 19:40, Oren wrote:

Hello! This is intentional. As the paragraph before the example says:
The child process is not killed if the timeout expires, so in order to cleanup properly a well-behaved application should kill the child process and finish communication
The kill() sends a signal that asks the process to exit, and the extra communicate waits until it actually exits. On 2/23/24 19:40, Oren wrote:
participants (2)
-
Oren
-
Petr Viktorin