Engine中用于长时间运行任务的任务队列

Engine中用于长时间运行任务的任务队列

本文介绍了FLEXIBLE App Engine中用于长时间运行任务的任务队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Flexible App Engine和Python3构建应用程序.在标准appengine中,如果您需要运行超过60s的任务,则可以使用taskqueue,也可以使用我成功完成的延迟库(taskqueue的抽象).

I am building an app using Flexible App Engine and Python3. In the standard appengine, if you needed to run a task that was longer than 60s, you could either use taskqueue, or the deferred library (an abstraction of taskqueue) which I have done successfully.

Flexible App Engine不再支持包含这些功能的appengine api.相反,功能已迁移到google-cloud库( https://googlecloudplatform.github.io/google-cloud-python/)( https://cloud.google.com/appengine/docs/flexible/python/migrating-an-existing-app ).

Flexible App Engine no longer supports appengine api which contains those functions. Instead, functionality is being migrated to the google-cloud library (https://googlecloudplatform.github.io/google-cloud-python/) instead (https://cloud.google.com/appengine/docs/flexible/python/migrating-an-existing-app).

您仍然可以使用python-compat配置(仅限于Python 2)访问这些appengine api功能.

You can still access these appengine api functionalities by using the python-compat configuration, which is limited to Python 2.

是否有一种方法可以在Flexible Appengine中运行长任务(排队)而不必使用python-compat配置?

Is there a way yet to run long tasks (queued) in Flexible Appengine without having to use the python-compat configuration?

推荐答案

我遇到了几乎完全相同的问题,以为问题出在这个截止日期之前,导致了错误

I had almost exactly the same problem Increase time to run code for Google flexible app engine delaying DeadlineExceededError, thinking that the problem was because of this deadlineexceedederror

但是因为这个问题询问了任务队列等问题,所以我认为答案可能有所不同.实际上,可以归结为以下事实:在python3的灵活环境中,此任务运行时间超过60s并不是一个约束,因为所有代码都在docker容器中运行.因此,甚至可能不需要运行任务队列等.

but because this question asked about taskqueue etc, i thought maybe the answer is different. Actually, it boils down to the fact that in flexible environment with python3 this task running longer than 60s is not a constraint since all the code runs in docker containers. Thus, running a taskqueue etc might not even be needed.

可能值得检查 gunicorn 入口点配置.在 app.yaml 文件中,添加 -t 选项和超时前允许的秒数.

It might be worth to check the gunicorn entrypoint config. In the app.yamlfile add the -t option and the number of seconds allowed before timeout.

runtime: python
env: flex
entrypoint: gunicorn -t 120 -b :$PORT main:app

这为我解决了这个问题,现在一个运行时间更长的代码没有退出.

this solved the issue for me, now a code which was longer was running without an exit.

这篇关于FLEXIBLE App Engine中用于长时间运行任务的任务队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 07:04