我试图在app引擎上运行任务,但我收到以下错误:
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
我这样做是为了添加任务:
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)
这是任务的代码:
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)
关于如何解决这个问题的任何想法?
修改
我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
答案 0 :(得分:1)
它看起来像导入错误“ImportError:没有模块命名的任务”。所以我认为以下是不正确的。
- url: /tasks
script: tasks.youtube_upload.app
问题中第二个区块的路径和文件名是什么?现在设置它的方式,您需要在/ tasks文件夹中包含youtube_upload.app,其中包含 init .py。