.close() gently stops the child process, .terminate() forcefully closes it.
I don’t know what usage scenario you need to use this function explicitly. I have never had this need when using concurrent.futures, so I use the with statement directly. After the task is processed, it will exit.
### example
import os
import signal
def handle_sigterm(signum, frame):
# do stuff
os._exit(0)
# subprocess
signal.signal(signal.SGITERM, handle_sigterm)
# where to kill subprocess
os.kill(pid, signal.SIGTERM)
You can use
pool.terminate()
to end the child process.https://docs.python.org/3/lib...
.close() gently stops the child process, .terminate() forcefully closes it.
I don’t know what usage scenario you need to use this function explicitly. I have never had this need when using concurrent.futures, so I use the with statement directly. After the task is processed, it will exit.