0
votes

I'm trying to deploy an API to Google Cloud on Google AppEngine, using python3 with the standard environment, and I want to use the defer function to put functions in Google CloudTasks, as seen here: https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/creating-tasks#using_the_instead_of_a_worker_service

I tried putting google.appengine on the requirements.txt file, where the python libraries are usually listed for pip install, adding a line with google-appengine, but it fails on deploy, with the following error message:

ModuleNotFoundError: No module named 'ez_setup'

I've added ez_setup to the list of requirements, before appengine, and it still results in the same error.

I've also tried deploying it without importing google.appengine, thinking it might come already installed, but then I get the expected error saying No module named 'google.appengine' on it's import. enter image description here

Is there something I'm missing on installation/import of this lib? Or is the library deprecated, and some new library is used to defer?

I've also tried to install the library on my local computer, and did not manage to install it here either.

2
Please don't post images of text, instead copy-paste the text in your post and format it accordingly. Thx.Dan Cornilescu

2 Answers

1
votes

As specified in the Public Documentation you have just Shared

The feature for creating tasks and placing them in push queues is not available for the python 3.7 runtime. That is the reason behind not being able to deploy it.

If you try it on Python 2.7 it should work without issues.

1
votes

As mentioned in @OqueliAMartinez's answer the feature you're seeking (the Task Queue API) isn't available in the python37/2nd generation standard environment. The documentation page you referenced is applicable only to the python27/1st generation standard environment.

For the other runtimes/environments, including python37, you need to use the Cloud Tasks API. Which, unfortunately, doesn't support (at least not yet) deferred tasks. From Features in Task Queues not yet available via Cloud Tasks API:

Deferred/delayed tasks:

In some cases where you might need a series of diverse small tasks handled asynchronously but you don't want to go through the work of setting up individual distinct handlers, the App Engine SDK allows you to use runtime specific libraries to create simple functions to manage these tasks. This feature is not available in Cloud Tasks. Note, though, that normal tasks can be scheduled in the future using Cloud Tasks.

The only way to defer functions in this case is to invoke them in the task queue handler on the worker side (and schedule the tasks in the future as needed to implement the deferral).

Somehow related: Cloud Tasks API for python2.7 google app engine