python - 找不到服务 "taskqueue"的 api 代理

标签 python django google-app-engine

当我尝试使用 python manage.py changepassword 命令时,出现此错误:

AssertionError: No api proxy found for service "taskqueue"

这是我的 PYTHONPATH 中的内容:

$ echo $PYTHONPATH
lib/:/usr/local/google_appengine

我的 DJANGO_SETTINGS_MODULE 指向我用于 GAE 的设置文件:

$ echo $DJANGO_SETTINGS_MODULE
settings.dev

appengine api 文件夹中有一些 taskqueue 包:

/usr/local/google_appengine/google/appengine/api/taskqueue$ ls
__init__.py  __init__.pyc  taskqueue.py  taskqueue.pyc  taskqueue_service_pb.py  taskqueue_service_pb.pyc  taskqueue_stub.py  taskqueue_stub.pyc

这里我会错过什么?

最佳答案

我假设manage.py正在执行sdk方法而不启动本地dev_appserverdev_appserver.py 设置 stub 以模拟部署应用程序后可用的服务。当您在本地和正在运行的应用程序服务器之外执行代码时,您需要自己初始化这些 stub 。

应用程序引擎文档中有一个关于测试的部分,它告诉您 how to initialize those stubs 。它不是您问题的确切解决方案,但它可以向您指出需要设置的 stub 。

import unittest

from google.appengine.api import taskqueue
from google.appengine.ext import deferred
from google.appengine.ext import testbed


class TaskQueueTestCase(unittest.TestCase):
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()

        # root_path must be set the the location of queue.yaml.
        # Otherwise, only the 'default' queue will be available.
        self.testbed.init_taskqueue_stub(root_path='tests/resources')
        self.taskqueue_stub = self.testbed.get_stub(
            testbed.TASKQUEUE_SERVICE_NAME)

    def tearDown(self):
        self.testbed.deactivate()

    def testTaskAddedToQueue(self):
        taskqueue.Task(name='my_task', url='/url/of/my/task/').add()
        tasks = self.taskqueue_stub.get_filtered_tasks()
        assert len(tasks) == 1
        assert tasks[0].name == 'my_task'

关于python - 找不到服务 "taskqueue"的 api 代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32992490/

相关文章:

python - 在 django-profile 中添加字段 first_name 和 last_name

java - NoSuchMethodError : com. google.appengine.api.memcache.ErrorHandlers.getConstantLogAndContinue

python - Scrapy 绕过带有表单例份验证的警报消息

python - 数据框中缺少数据

javascript - Python 套接字问题 : How To Get Reliably POSTed data whatever the browser?

macos - 如何卸载 Google App Engine SDK

python - Google App Engine - 将 key 存储到ndb KeyProperty中

python - 如何使用 h5py 在 python 中导入 .mat -v7.3 文件但具有相同的维度顺序?

django - 如何使用 Django 连接两个表而不使用原始 sql?

django - 检索邻居的查询太慢