Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 找不到服务的api代理;“任务队列”;_Python_Django_Google App Engine - Fatal编程技术网

Python 找不到服务的api代理;“任务队列”;

Python 找不到服务的api代理;“任务队列”;,python,django,google-app-engine,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\u设置\u模块指向我用于GAE的设置文件: $ echo $DJANGO_SETTINGS_MODULE setti

当我尝试执行
python manage.py changepassword
命令时,出现以下错误:

AssertionError: No api proxy found for service "taskqueue"
以下是我的
PYTHONPATH中的内容:

$ echo $PYTHONPATH
lib/:/usr/local/google_appengine
我的
DJANGO\u设置\u模块
指向我用于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_appserver.py
设置存根,以便在部署应用程序后模拟可用的服务。当您在本地和运行的应用服务器外部执行代码时,您需要自己初始化这些存根

appengine文档中有一个关于测试的部分告诉您。这不是解决问题的确切方法,但它可以为您指出需要设置的存根

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'

上述解决方案用于测试。我试图在中间件中使用taskqueue,但遇到了这个错误<代码>从google.appengine.api导入apiproxy\u stub\u map apiproxy\u stub\u map.apiproxy=apiproxy\u stub\u map.GetDefaultAPIProxy()
在设置中尝试此操作。py无效。提前谢谢。@Pannu如果您有关于如何做某事的问题,我建议您创建一个新问题,而不是对此答案进行评论。应用程序引擎变化迅速,2015年的相关内容现在不再相关。