Using Task Queues with the new GAE Modules

902 views Asked by At

I have a GAE application which has an app.yaml that describes the request handlers and uses the deferred extension to put tasks onto a push queue which is targeted at a backend also defined in my application.

However, I've seen notices in the GAE dashboard saying "you're using backends, you should look at modules". So I've looked at modules and I'm having some difficulty figuring out how to define my backend as a module. My backend does not need any explicitly defined request handlers. It only processes tasks from the queue. But when I create the module yaml file for the backend with no handlers, the dev server complains that it's an invalid file.

I tried using the backend_conversion.py file and that duplicates the request handlers from my default module into my backend module, which seems to work, but it feels wrong.

The project source can be found here and the branch with the module conversion is here.

Any advice would be appreciated.

2

There are 2 answers

1
Gianni Di Noia On

You can set the directive target to the queue definition in queue.yaml:

- name: solver_queue
  ...
  target: solver_backend

and add the parameter _queue to the deferred.defer:

deferred.defer(function, param1, param2, _queue='solver_queue')
1
lucemia On

My backend does not need any explicitly defined request handlers. It only processes tasks from the queue.

The reason why you may feel backend_conversion.py is wrong is because it duplicates your handlers and you feel your backend don't need handlers before. But backend needs handlers as frontend instance. What you backend actually did is running your whole app (defined by app.yaml) on backend instance. Thus your frontend instance and backend instance actually share the same code before.

Therefore

the backend_conversion.py file and that duplicates the request handlers

is a right behaviour.