如何从 Eclipse pydev 捕获运行终止?

发布于 2024-12-29 10:38:47 字数 105 浏览 1 评论 0原文

我有一个使用多处理的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

携君以终年 2025-01-05 10:38:47

通过捕获 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文