扫码关注官方订阅号
学习是最好的投资!
可以用 pool.terminate() 来结束子进程。https://docs.python.org/3/lib...
pool.terminate()
.close() 温和地停止子进程,.terminate() 强制关。
不知道你是什么使用场景需要显式地用这种功能。我用 concurrent.futures 的时候从来没有过这种需求,直接用 with 语句。任务处理完了也就退出了。
### 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)
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
可以用
pool.terminate()
来结束子进程。https://docs.python.org/3/lib...
.close() 温和地停止子进程,.terminate() 强制关。
不知道你是什么使用场景需要显式地用这种功能。我用 concurrent.futures 的时候从来没有过这种需求,直接用 with 语句。任务处理完了也就退出了。