python - 有没有办法获取谷歌云任务状态?

标签 python google-cloud-tasks

我正在使用 python 和 google.cloud.tasks_v2。在应用程序引擎中部署我的服务后,我创建任务,它创建并成功执行,但是如果方法 client.get_task() 不返回任何相关信息,我如何获取任务状态或任务执行结果?

最佳答案

要获取有关您正在运行的指定云任务的信息,您可以使用 command line并使用像 subprocess 这样的包将其集成到您的 Python 代码中来运行以下命令:

gcloud 任务描述 TASK [--queue=QUEUE]

此外,如果您想查看任务尝试的状态,您可以使用以下命令 Cloud Task API.

它将通过以下 JSON 表示形式为您提供有关任务尝试状态的信息:

{
  "scheduleTime": string,
  "dispatchTime": string,
  "responseTime": string,
  "responseStatus": {
    object (Status)
  }
}

要查看任务第一次尝试 firstAttempt 的状态或任务最后一次尝试 lastAttempt 的状态,您可以使用 following method在云任务 API 中。

如上所述here,请记住,如果您在 Cloud Tasks 队列中使用 App Engine 任务,则代码状态将如下所示:

The task attempt has succeeded if the app's request handler returns an HTTP response code in the range [200 - 299]. The task attempt has failed if the app's handler returns a non-2xx response code or Cloud Tasks does not receive response before the deadline.

关于python - 有没有办法获取谷歌云任务状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59469004/

相关文章:

python - 如何使用 pandas python 获取系列的重复值及其索引?

python - 使用 Python 的 "from"关键字?

python - 获取错误类型错误 : create_task() takes from 1 to 2 positional arguments but 3 were given while creating google cloud tasks

python - 谷歌云任务导入错误 : cannot import name 'resource_pb2'

google-cloud-platform - 尽管有大量积压和可用实例,Google Cloud Run 仍未扩展

python - 如何使用 BeautifulSoup 从源代码获取数组数据?

python - 我怎样才能修改这个代码,这样我就不会每次都重新绘制我的图,matplotlib

python - 有没有办法在Python中使用Selenium获取Web元素的outerHTML的outerHTML?

node.js - 检查云任务队列是否为空

node.js - Node.js 中 GAE 基本扩展的并发性