Tornado 非阻塞 SMTP 客户端
我正在寻找 python 异步 SMTP 客户端以将其与 Torando IoLoop 连接。我发现只有简单的实现(http://tornadogists.org/907491/),但它是一个阻塞解决方案,所以它可能会带来性能问题。
有人遇到过 Tornado 的非阻塞 SMTP 客户端吗?一些代码片段也非常有用。
I'am looking for python async SMTP client to connect it with Torando IoLoop. I found only simple implmementation (http://tornadogists.org/907491/) but it's a blocking solution so it might bring performance issues.
Does anyone encountered non blocking SMTP client for Tornado? Some code snippet would be also very useful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
仅供参考 - 我刚刚创建了一个基于 ioloop 的 smtp 客户端。虽然我不能说它已经过生产测试,但它将在不久的将来进行。
https://gist.github.com/1358253
Just FYI - I just whipped up a ioloop based smtp client. While I can't say it's production tested, it will be in the near future.
https://gist.github.com/1358253
https://github.com/equeny/tornadomail - 这是我移植 django 邮件系统和 python 的尝试smtplib 到龙卷风 ioloop。
将很高兴听到一些反馈。
https://github.com/equeny/tornadomail - here is my attemp to port django mail system and python smtplib to tornado ioloop.
Will be happy to hear some feedback.
我在工作中寻找同样问题的解决方案。由于没有现成的解决方案,我将Python smtplib移植到基于tornado非阻塞IOStream的实现上。语法尽可能接近 smtplib 的语法。
目前仅支持Python 3.3及以上版本。这是 github 存储库
I was looking for the solution to the same problem at work. Since there was no readily available solution, I ported Python smtplib to implementation based on tornado non-blocking IOStream. The syntax follows that of smtplib as close as possible.
It currently only supports Python 3.3 and above. Here's the github repo
我编写了基于线程和队列的解决方案。每个龙卷风进程一个线程。该线程是一个工作线程,从队列中获取电子邮件,然后通过 SMTP 发送。您可以通过将龙卷风应用程序添加到队列来发送电子邮件。简单又容易。
以下是 GitHub 上的示例代码:链接
I wrote solution based on threads and queue. One thread per tornado process. This thread is a worker, gets email from queue and then send it via SMTP. You send emails from tornado application by adding it to queue. Simple and easy.
Here is sample code on GitHub: link
我没有使用自己的 SMTP 服务器,但认为这对某人有用:
我只需将电子邮件发送添加到我的应用程序。大多数用于网络电子邮件服务的示例 python 代码都使用阻塞设计,因此我不想使用它。
Mailchimp 的 Mandrill 使用 HTTP POST 请求,因此它可以以符合 Tornado 设计的异步方式工作。
I'm not using my own SMTP server but figured this would be useful to someone:
I've just had to add email sending to my app. Most of the sample python code for the web emailing services use a blocking design so I dont want to use it.
Mailchimp's Mandrill uses HTTP POST requests so it can work in an Async fashion fitting in with Tornado's design.