python3.x - Python多进程的子进程终止问题
PHPz
PHPz 2017-04-18 09:58:08
0
3
986
PHPz
PHPz

学习是最好的投资!

reply all(3)
伊谢尔伦

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.

PHPzhong
###  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)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template