Google AppEngine - 拉队列 - 无法删除任务:“项目名称无效”

时间:2016-09-04 18:57:12

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

我在GAE中创建了一个工作正常的拉取队列,我可以从应用程序中添加元素。使用以下代码从我的实例中检索它们:

from apiclient.discovery import build
from oauth2client.client import GoogleCredentials

credentials = GoogleCredentials.get_application_default()
PROJECT_NAME = "my-project"
QUEUE_NAME = 'my-queue'

q = build('taskqueue', 'v1beta2', credentials=credentials)
l = q.tasks().lease(project=PROJECT_NAME, taskqueue=QUEUE_NAME, leaseSecs=600, numTasks=1)
result = l.execute()
task = result['items'][0]
task_id = task['id']

当我尝试在处理任务后删除任务时,问题就出现了,这个代码应该可以运行

d = q.tasks().delete(project=PROJECT_NAME, taskqueue=QUEUE_NAME, task=task_id)
d.execute()

返回

File "/usr/local/lib/python2.7/dist-packages/oauth2client/util.py", line 137, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/googleapiclient/http.py", line 838, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting
https://www.googleapis.com/taskqueue/v1beta2/projects/my-project/taskqueues/my-queue/tasks/46101672956060486431?
returned "project name is invalid">

我不明白什么是错的,因为我能够从队列中获取任务,但是当我想删除它时,会引发此错误。

有没有人有洞察力?

1 个答案:

答案 0 :(得分:1)

如果您的应用位于北美,则为"s~my-project";如果位于欧洲,则应为"e~my-project"