为什么我的 Google App Engine Mail API 调用仍然会导致 DeadlineExceededError,尽管将它们放入任务队列中?
我有一个 Python 函数,它为我的邮件列表中的每个电子邮件地址添加一个任务队列(每次邮寄数千个)。问题是,即使每封邮件都是通过任务队列中的执行发送的,我仍然收到这个可怕的错误:
DeadlineExceededError:API 调用 mail.Send() 花了太长时间来响应并被取消。< /code>
有什么解决办法吗?
I have a Python function that adds a task queue for each email address in my mailing list (thousands each time I mail them). The problem is that, even though each mail was to be sent via execution in a task queue, I still get this dreaded error:
DeadlineExceededError: The API call mail.Send() took too long to respond and was cancelled.
Any solutions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
截止时间发生在 GAE 实例与处理
mail.Send
调用的 RPC 服务器之间的通信期间。反过来,这可能表明 GAE 存在内部问题或(更有可能)无法及时与 SMTP 服务器通信。后者在概念上与 URLFetch 调用的截止时间非常相似。但是,可以为 URLFetch 设置自定义截止时间,这在很大程度上缓解了该问题。
不幸的是,没有关于 Mail API 的类比记录。不过,有一个解决方法,即提供您自己的
make_sync_call
方法(该方法允许更宽松的截止日期)作为EmailMessage.send()
的参数。要生成这样的方法,您需要深入研究用于进行 GAE RPC 调用的 Python 接口的内部结构。我发现可行的解决方案如下所示:然后,您可以使用它来提供自定义截止日期,生成的
make_sync_call
方法将遵守该截止日期:如果您想了解更多有关 GAE 幕后发生的事情RPC 调用,我建议阅读 Nick Johnson 的博客文章它。如果您想要通过 Python 的 GAE RPC 绑定来解决类似问题,那么这是一个很好的起点。
The deadline happens during communication between your GAE instance and the RPC server that handles the
mail.Send
call. This, in turn, might indicate internal problems of GAE or (more likely) failure to communicate with SMTP server in timely manner.The latter is conceptually very similar to deadline on URLFetch call. It is possible, however, to set a custom deadline for URLFetch which largely alleviates that problem.
Unfortunately, there is no documented analogy for Mail API. There is workaround, though, that involves providing your own
make_sync_call
method - which allow for more lenient deadline - as parameter ofEmailMessage.send()
. To produce such a method, you need to delve into the internals of Python's interface used to make GAE RPC calls. The solution I find working looks as follows:You can then use it to supply your custom deadline which will be honored by the resulting
make_sync_call
method:If you want to know more about what happens under the curtains of GAE RPC calls, I suggest reading Nick Johnson's blog post about it. This is good starting point if you'd ever want to go through the Python's GAE RPC bindings in order to solve similar issues.