Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google App Engine deferred.defer() error 404

I'm trying to get running a task in the Task Queue using deferred.defer(). The task is added to the default task queue, but the task fail with a 404 error.

This is the handler:

import webapp2
import models

import defer_ajust_utils

from google.appengine.ext import ndb
from google.appengine.ext import deferred

class ajust_utils(webapp2.RequestHandler):
  def get(self):
    deferred.defer(defer_ajust_utils.DoTheJob)

application = webapp2.WSGIApplication([('/ajust_utils', ajust_utils)], debug=True)

This is the module defer_ajust_utils :

import logging
import models 
from google.appengine.ext import ndb

def DoTheJob():
  logging.info("Debut de la mise a jour des utilisateurs")
  utilisateurs = models.Utilisateur.query()
  utilisateurs = utilisateurs.fetch()

  for utilisateur in utilisateurs:
    utilisateur.produire_factures_i = False
    utilisateur.put()  

  logging.info("Fin de la mise a jour des utilisateurs")

And my app.yaml file :

application: xxxx
version: dev
runtime: python27
api_version: 1
threadsafe: yes

builtins:
- deferred: on

handlers:
- url: /ajust_utils
  script : tempo_ajuster_utils.application
  login: admin

Here's the log :

0.1.0.2 - - [10/Mar/2014:17:50:45 -0700] "POST /_ah/queue/deferred HTTP/1.1" 404 113
"http://xxxx.appspot.com/ajust_utils" "AppEngine-Google;
(+http://code.google.com/appengine)" "xxxx.appspot.com" ms=6 cpu_ms=0 
cpm_usd=0.000013 queue_name=default task_name=17914595085560382799 
app_engine_release=1.9.0 instance=00c61b117c0b3648693af0563b92051423b3cb

Thank you for help!!

like image 712
Sly Boudreault Avatar asked Mar 11 '14 01:03

Sly Boudreault


1 Answers

If you are using push-to-deploy with git, when you add in a 'builtin' part to the app.yaml, such as in

builtins: - deferred: on

you need to do a 'normal' gcloud deploy before you run the app. Otherwise it will not update the running app, which causes 404 errors for /_ah/queue/deferred

There is an open bug for this, so vote for it and it may get fixed. https://code.google.com/p/googleappengine/issues/detail?id=10139

like image 142
nik Avatar answered Oct 05 '22 03:10

nik