从googlecloud中的操作名轮询longlunning操作的Python方式?

2024-04-29 20:29:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在调用一个Google云函数,它返回一个实现google.longrunning.Operations接口的Operation对象。我想从另一个Python进程轮询这个操作,这个进程只接收操作名(不能访问操作对象本身)。所以我需要这样的东西:

operation = getOperation(operationName)
isdone = operation.done()

阿菲,你不能做上面的第一步。我在这里没找到:https://google-cloud-python.readthedocs.io/en/stable/core/operation.html

我想做文档中关于google.longrunning接口(https://cloud.google.com/speech-to-text/docs/reference/rpc/google.longrunning#google.longrunning.Operations.GetOperation)的说明:

^{pr2}$

其中GetOperationRequest只需要操作名。有没有办法使用google-cloud-python库中的函数“重新创建”操作?在


Tags: 对象函数httpscloud进程googleoperationoperations
1条回答
网友
1楼 · 发布于 2024-04-29 20:29:20

您可以使用"Long-Running Operations Client"^{}方法:

from google.api_core import operations_v1
api = operations_v1.OperationsClient()
name = ...
response = api.get_operation(name)

相关问题 更多 >