Local dev server: 'Task task1 failed to execute' due to ' The resource could not be found.'

278 views
Skip to first unread message

A. Kong

unread,
Jan 7, 2016, 8:28:58 PM1/7/16
to Google App Engine
Hi,

When I tried to use taskqueue to execute a task in local dev server, I encounter the said exception and the task simply fails to be executed.

Here is more information:


Queue definition:


- name: votecounter
rate: 1/s
max_concurrent_requests: 1
target: app


Python code:

taskqueue.add(url, queue_name='votecounter')

Here is the exception stacktrace


WARNING  2016-01-08 01:16:41,722 main.py:135] handle 404
WARNING  2016-01-08 01:16:41,723 main.py:136] The resource could not be found.
Traceback (most recent call last):
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1265, in default_dispatcher
    route, args, kwargs = rv = self.match(request)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1214, in default_matcher
    raise exc.HTTPNotFound()
HTTPNotFound: The resource could not be found.
INFO     2016-01-08 01:16:41,787 module.py:794] app: "POST /_ah/queue/votecounter HTTP/1.1" 404 1218
WARNING  2016-01-08 01:16:41,788 taskqueue_stub.py:1977] Task task1 failed to execute. This task will retry in 0.100 seconds

Apparently the same code can run OK on the app engine server. How can I enable taskqueue in a local dev environment?

Cheers

A. Kong

unread,
Jan 7, 2016, 9:12:08 PM1/7/16
to Google App Engine
I did more digging and I realised the url is actually marked as 'secure' in app.yaml. Maybe the task execution fails due to a 302, which is not captured in the log?


That's why when I test the url in a browser, it returns OK.


So what is the best practice in term of which url to pass to the taskqueue.add?

Christian F. Howes

unread,
Jan 8, 2016, 3:00:26 PM1/8/16
to Google App Engine
are you using a fully qualified URL or a relative URL?  i use a relative URL and let the taskqueue handler figure it out.

note that you can use secure with URLs accessed by the task queue.

A. Kong

unread,
Jan 13, 2016, 10:51:51 PM1/13/16
to Google App Engine
It turns out I need to use 'url=url' instead just url as the first positional parameter

Thanks for your suggestion!

Cheers
Reply all
Reply to author
Forward
0 new messages