Google App Engine 任务队列:文件上传时出现 DeadlineExceededError
我正在上传一个大文件。整个请求可能需要超过 30 秒的限制,因此我将其移至任务队列。问题是我仍然收到此错误,即使在任务中也是如此。
我假设这是因为它是上传文件的单个请求,因此不能不受 30 秒限制的影响。除了使用“后端”解决方案(我认为应用程序引擎刚刚添加了这个,但它是一个付费功能,看起来有点复杂)之外,还有什么方法可以绕过这个限制?不幸的是,我无法拆分该文件。
编辑:抱歉造成混乱。我所说的上传是指上传到国外服务器。场景是我从数据存储中提取数据并将其上传到 Google 文档电子表格。将其上传到 Google 文档的单个请求(即使它位于任务队列中)也超过 30 秒并超时。
I have a large file I'm uploading. The entire request can take more than the 30 second limit, so I moved it to a task queue. The problem is that I'm still getting this error, even in a task.
I'm assuming this is because it's a single request to upload a file, and is not immune to the 30-second limit because of this. Is there any way to circumvent this limit, aside from using a 'backend' solution (App engine just added this I think, but it's a pay feature and looks a bit complicated)? I can't split up the file, unfortunately.
EDIT: Sorry for the confusion. By uploading, I mean uploading to a foreign server. The scenario is that I'm pulling data from the data store and uploading it to Google Docs Spreadsheets. The single request to upload it to Google Docs, even though it's in the Task Queue, is exceeding 30 seconds and timing out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能会收到两种类型的 DeadlineExceeded - 一种是由于请求超时,另一种是由于 URLFetch 调用超时。任务队列上的请求截止时间是 10 分钟,但 URLFetch 调用的默认截止时间是 5 秒,因此您几乎肯定会得到后者。
您可以通过提供
timeout
参数来延长 URLFetch 调用的截止时间。交互式请求中的时间限制为 10 秒,任务队列请求中的时间限制为 10 分钟。There are two types of DeadlineExceeded you could be getting - one is due to the request timing out, and the other is due to the URLFetch call timing out. Request deadlines on the task queue are 10 minutes, but the default deadline for a URLFetch call is 5 seconds, so you're almost certainly getting the latter.
You can increase the deadline of your URLFetch call by supplying the
timeout
parameter. This is limited to 10 seconds in an interactive request, and 10 minutes in a task queue request.除了请求时间限制外,还有 32Mb 的请求大小限制。如果超出此范围,则必须使用替代解决方案,例如 Blobstore 或外部存储。
Aside the request time limit, there's also a request size limit of 32Mb. If you are you exceeding this, you must use an alternative solution, like Blobstore or external storage.