Routing with dispatch.yaml not working from within app

235 views
Skip to first unread message

Kirill Kireyev

unread,
Dec 2, 2015, 6:57:03 PM12/2/15
to Google App Engine
Hi,

I have a GAE app with two modules, default and "background". My dispatch.yaml file says:

dispatch:

  - url: "*/cron/*"

    module: background

  - url: "*/_ah/queue/deferred"

    module: background

  - url: "*/background_tasks/*"

    module: background


When I enter a "http://MYHOST/background_tasks/XXX" from my web browser, the task is indeed handled by the "background" module.


However, when the task is run from within my app:

taskqueue.add(url="/background_tasks/XXX"), queue_name="YYY")


The task is handled by the default module (I've verified this by looking at the GAE logs in Dev Console for each of the two modules separately).


Can someone please help me understand why this discrepancy?


Thanks,

Kirill

Adam

unread,
Dec 4, 2015, 4:53:52 PM12/4/15
to Google App Engine
You can try using the target parameter to explicitly specify the module the task should run on. According to the docs, the HTTP may be intercepted by the dispatch routing rule, so this seems to imply it doesn't always happen.

Cheers,

Adam
Cloud Platform Support

Christian F. Howes

unread,
Dec 5, 2015, 3:44:53 PM12/5/15
to Google App Engine
I'll agree that i have seen similar issues and now as a matter of habit always specify my intended target when queuing tasks.

It would be great to update the documentation to make that more obvious. :)

cfh

Kirill Kireyev

unread,
Dec 6, 2015, 3:42:06 PM12/6/15
to Google App Engine
Thanks Adam and Christian! I will add the target parameter to taskqueue.add()
Reply all
Reply to author
Forward
0 new messages