Python:为什么我的 SMTP 脚本冻结了我的计算机?

发布于 2024-11-02 20:00:21 字数 287 浏览 0 评论 0原文

所以我写了一个小的多线程 SMTP 程序。问题是每次我运行它时,它都会很快冻结计算机。该脚本似乎仍然有效,因为我的网卡仍然亮着并且收到了电子邮件,但在某些情况下它会完全锁定并停止发送电子邮件。

这是我的两个脚本文件的链接。第一个是用于启动程序的:

readFile.py newEmail.py

So I wrote a little multithreaded SMTP program. The problem is every time I run it, it freezes the computer shortly after. The script appears to still work, as my network card is still lighting up and the emails are received, but in some cases it will lock up completely and stop sending the emails.

Here's a link to my two script files. The first is the one used to launch the program:

readFile.py
newEmail.py

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

猥琐帝 2024-11-09 20:00:21

首先,您使用 popen 创建子流程,即。进程而不是线程。我假设这就是你的意思。

我的猜测是,程序陷入了不断生成进程的循环中,操作系统可能会不喜欢这种情况。 (这种东西被称为forkbomb,这是冻结 Linux 的好方法,除非进程限制已使用 ulimit 设置。)虽然我找不到该错误,但如果我是你,我会在每次生成或终止子进程时记录消息,如果一切正常,密切观察系统(Unix 系统上的 pstop)查看进程是否真的被杀死。

First, you're using popen which creates subprocesses, ie. processes not threads. I'll assume this is what you meant.

My guess would be that the program gets stuck in a loop where it generates processes continuously, which the OS will probably dislike. (That kind of thing is known as a forkbomb which is a good way to freeze Linux unless a process limit has been set with ulimit.) I couldn't find the bug though, but if I were you, I'd log messages each time I spawn or kill a subprocess, and if everything is normal, watch the system closely (ps or top on Unix systems) to see if the processes are really being killed.

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