问题
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 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).
You can still access these appengine api functionalities by using the python-compat configuration, which is limited to Python 2.
Is there a way yet to run long tasks (queued) in Flexible Appengine without having to use the python-compat configuration?
回答1:
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
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.
It might be worth to check the gunicorn
entrypoint config. In the app.yaml
file 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.
来源:https://stackoverflow.com/questions/39539657/taskqueue-for-long-running-tasks-in-flexible-app-engine