Google App Engine错误未知任务队列

时间:2017-07-17 01:55:22

标签: google-app-engine google-app-engine-python

我刚刚部署了appengine应用程序,当我休息时,调用触发队列,我得到UnknownQueueError。看来异常是在下面的源代码行中抛出的。关于导致问题的原因的任何想法。我在本地进行测试,效果非常好。

 q.add(task)

异常

Exception on /tasks/stock/prices/dispatch [GET]
Traceback (most recent call last):
File "/base/data/home/apps/s~xxxxx-173913/internal-
api:20170716t091842.402709903291335684/lib/flask/app.py", line 1817, 
in wsgi_app
response = self.full_dispatch_request()
File "/base/data/home/apps/s~xxxxx-173913/internal-
api:20170716t091842.402709903291335684/lib/flask/app.py", line 1477, 
in full_dispatch_request
rv = self.handle_user_exception(e)
File "/base/data/home/apps/s~xxxx-173913/internal-
api:20170716t091842.402709903291335684/lib/flask/app.py", line 1381, 
in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/base/data/home/apps/s~xxxxxx-173913/internal-
api:20170716t091842.402709903291335684/lib/flask/app.py", line 1475, 
in full_dispatch_request
rv = self.dispatch_request()
File "/base/data/home/apps/s~xxxxxx-173913/internal-
api:20170716t091842.402709903291335684/lib/flask/app.py", line 1461, 
in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/base/data/home/apps/s~xxxx-173913/internal-apixxx/
internal/tasks/stock_prices_dispa
tch.py", line 34, in run
q.add(task)
File"/base/data/home/runtimes/python27/python27_lib
/versions/1/google/appengine/api/taskqueue/taskqueue.py",
line 2128, in add
return self.add_async(task, transactional).get_result()
File"/base/data/home/runtimes/python27/python27_lib
/versions/1/google/appeng
ine/api/apiproxy_stub_map.py", line 613, in get_result
return self.__get_result_hook(self)
File "/base/data/home/runtimes/python27/
python27_lib/versions/1/google/appeng
ine/api/taskqueue/taskqueue.py", line 2162, in ResultHook
raise exception
UnknownQueueError

源代码

 task = Blueprint('tasks.stock.prices.dispatch', __name__)
 @task.route('/tasks/stock/prices/dispatch')
 def run():
  q = taskqueue.Queue('push-queue')
  from_date = request.args.get('from')
  to_date = request.args.get('to')

  with open(os.path.join(os.path.dirname(__file__), 
            "../resources/dow_30.csv")) as csvfile:

    reader = csv.DictReader(csvfile)
    for row in reader:
        ticker = row['TICKER']
        stock_code = row['StockCode']

        task = taskqueue.Task(
            url='/tasks/stock/prices/shard',
            target='internal-api',
            headers={'Content-Type' : 'application/json'},
            payload=json.dumps({'ticker': ticker, 'stock_code': stock_code, 'from' : from_date, 'to' : to_date}))

        logging.info("StockCode :=" + stock_code)

        q.add(task)

return "OK"

1 个答案:

答案 0 :(得分:2)

当我部署应用程序时,我忘了部署queue.yaml。一旦我做了以下(由@DanCornilescu提供),它解决了这个问题。

gcould app deploy <path_to_your_queue.yaml>