Question

Do jobs on the task queue in Google App Engine automatically get put on the default backend or do they get scheduled on the backend version for the code calling them?

Let's say I have two backends one called 'test' and one called 'production' where 'production' is my default version.

In each of them, I have a file trivialized as follow:

from google.appengine.api import taskqueue
import webapp2

class QueueScheduler(webapp2.RequestHandler):
    def get(self): #in real life, post, but this makes for an easier example
        taskqueue.add('path/to/myTask')

app = webapp2.WSGIApplication(('/myScheduler',QueueScheduler))

When I make a call to test.myApp.appspot.com/myScheduler, will I create task pointing at test.myApp.appspot.com/path/to/myTask or will I be creating a task to myApp.appspot.com/path/to/myTask (i.e.production.myApp.appspot.com/path/to/myTask)

Is there a way for me to control this from code? Let's say I have a third backend called 'queues'. Is there some way I could change the above code, so that calls to test.myAppp.appspot.com/myScheduler, production.myApp.appspot.com/myScheduler, and queues.myApp.appspot.com/myScheduler all would generate a task to call the code reached by going to queues.myApp.appspot.com/path/to/myTask while keeping 'production' as the default backend version?

meta: In case it matters, the particular problem I'm dealing with is that my company uses a different version of our code for our mobile app than we do for the web app. We hard code a version number into our apps to keep the apps pointed at the version that was default when we released the update so that we can make backwards incompatible revisions. It's also frequently the case that we want to be updating our data processing before we are updating the interface our users see. I am looking for a solution that allows us to do this without either having to make sure that we aren't revising our data processing while we have partially finished changes to the interface or working with multiple branches of our code at once. We'd like calls to both the default and the legacy versions of our app to be able to have their data processing done on a version that is not-yet-ready to be client facing. Creating tasks in the cron.yaml and setting the version there solves the problem for all of the data that we have to keep live, but for certain things we'd rather have the programming overhead of developing in multiple branches than the problem of not keeping the data real time.

Was it helpful?

OTHER TIPS

This documentation for the add function actually has a better treatment of this exact subject.

https://developers.google.com/appengine/docs/python/taskqueue/functions#add

The target argument lets you control what version is used, so you can set it once in code and have it apply to all of the versions you have deployed which is exactly what I was looking for when I asked the question.

In short, by default, tasks run on the backend that the url initiating the task was on, but it is possible to control what version of your app the task queue runs on from code. To do this, simply call taskqueue.add('/relative/path/to/task',target='queues')

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top