[英]Is there any way to get google cloud task status?
I am using python and google.cloud.tasks_v2.我正在使用 python 和 google.cloud.tasks_v2。 After deploying my service in app engine I create task and it creates and executing successfully, but how I can get the task status or the result of task execution if method client.get_task() do not return any information about that?
在应用程序引擎中部署我的服务后,我创建了任务并成功创建并执行,但是如果方法 client.get_task() 不返回任何相关信息,我如何获取任务状态或任务执行结果?
For getting information about a specified Cloud Task that you are running, you can use the command line and integrate it into your Python's code using a package like subprocess
to run the following command:要获取有关您正在运行的指定 Cloud Task 的信息,您可以使用命令行并使用
subprocess
类的包将其集成到 Python 代码中,以运行以下命令:
gcloud tasks describe TASK [--queue=QUEUE]
Moreover, if you would like to see the status of a task attempt you can use the following for the Cloud Task API.此外,如果您想查看任务尝试的状态,您可以将以下内容用于Cloud Task API。
It will give you information about the status of a task attempt with the following JSON representation:它将使用以下 JSON 表示为您提供有关任务尝试状态的信息:
{
"scheduleTime": string,
"dispatchTime": string,
"responseTime": string,
"responseStatus": {
object (Status)
}
}
To see the status of the task's first attempt firstAttempt
or the status of the task's last attempt lastAttempt
you can use the following method within the Cloud Task API.要查看任务第一次尝试
firstAttempt
的状态或任务最后一次尝试lastAttempt
的状态,您可以在 Cloud Task API 中使用以下方法。
As stated here, please bear in mind that if you are using App Engine tasks within a Cloud Tasks queue, the code status will be as follow:如此处所述,请记住,如果您在 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].
如果应用程序的请求处理程序返回 [200 - 299] 范围内的 HTTP 响应代码,则任务尝试成功。 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.
如果应用程序的处理程序返回非 2xx 响应代码或 Cloud Tasks 在截止日期前未收到响应,则任务尝试失败。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.