如何从 Eclipse pydev 捕获运行终止?
我有一个使用多处理的 python 脚本。我喜欢在 Eclipse 中调试脚本,但是对于多重处理,我总是必须在终止后手动终止生成的子进程。如何捕获脚本中的 Eclipse 终止操作以便它可以清理?
I have a python script which makes use of multiprocessing. I like to debug my scripts in Eclipse, but with multiprocessing, I always have to manually kill the spawned children processes after termination. How can I catch the Eclipse termination action in the script so it can clean up?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过捕获 Eclipse 终止,您的意思是捕获某人在调试时按下“终止”按钮的事件吗?如果是这样,我认为您无法捕获异常或事件。
这是我在侧面尝试过的一些方法,但也不起作用:
1. 添加 SIGTERM、SIGNTEAL 和 SIGINT 的信号处理程序,但没有成功。
2.尝试atexit模块,它只能正常程序终止。
By catching the eclipse termination, do you mean catching the event of someone pressing the "Terminate" button while debugging? If so, I don't think there is an exception or event you can catch.
Here is a few things i tried on the side that does not work either:
1. Adding signal handlers for SIGTERM, SIGNTEAL, and SIGINT, but no luck.
2. try the atexit module, it only works only normal program termination.