伊谢尔伦2017-04-18 10:00:08
You can use pool.terminate()
to end the child process.
https://docs.python.org/3/lib...
高洛峰2017-04-18 10:00:08
.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.
PHPz2017-04-18 10:00:08
### 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)