I’m trying to run a task on app engine, but i’m getting the following error:
ERROR 2012-07-24 18:47:01,030 wsgi.py:189]
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 187, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 225, in _LoadHandler
handler = __import__(path[0])
ImportError: No module named tasks
INFO 2012-07-24 18:47:01,040 dev_appserver.py:2952] "POST /tasks HTTP/1.1" 500 -
WARNING 2012-07-24 18:47:01,045 taskqueue_stub.py:1934] Task task22 failed to execute. This task will retry in 0.100 seconds
I’m doing this to add the task:
import os
import webapp2
from google.appengine.ext.webapp import blobstore_handlers
from controllers.basehandler import BaseHandler
from google.appengine.ext import blobstore
from google.appengine.api import taskqueue
from google.appengine.ext.webapp.util import run_wsgi_app
class UploadHandler(blobstore_handlers.BlobstoreUploadHandler, BaseHandler):
def post(self):
upload_files = self.get_uploads('video_file')
blob_info = upload_files[0]
current_user = self.current_user
if current_user:
if current_user.video_file_bob:
old_video = current_user.video_file_bob.key()
blobstore.delete(old_video)
current_user.video_file_bob = blob_info.key()
current_user.put()
params = {'user':current_user}
taskqueue.add(url='/tasks')
self.redirect('/video_upload')
app = webapp2.WSGIApplication([('/store_video', UploadHandler)],
debug=True)
and this is the code for the task:
import re
import urlparse
import webapp2
from google.appengine.ext import blobstore
from controllers.basehandler import BaseHandler
import gdata.youtube.service
from google.appengine.api import taskqueue
from google.appengine.ext.webapp.util import run_wsgi_app
import logging
class YoutubeUpload(BaseHandler):
def post(self):
logging.info('Here')
app = webapp2.WSGIApplication([('/tasks', YoutubeUpload)],
debug=True)
any ideas on how to solve this?
EDIT
The content of my app.yalm:
application: traapp
version: 1
runtime: python27
api_version: 1
threadsafe: True
handlers:
- url: /images
static_dir: assets/images
- url: /link_submit
script: controllers.video_link_submit.app
- url: /video_upload
script: controllers.video_upload.app
- url: /store_video
script: controllers.video_upload_handler.app
- url: /tasks
script: tasks.youtube_upload.app
login: admin
- url: /.*
script: controllers.login.app
libraries:
- name: PIL
version: latest
builtins:
- appstats: on
It looks like an import error “ImportError: No module named tasks”. So I would think that the following would be incorrect.
What is the path and filename of the second block in your question? The way you have it setup now, you would need to have youtube_upload.app in a /tasks folder that had an init.py in it as well.