【发布时间】:2019-10-29 10:40:06
【问题描述】:
我想在我的云函数中运行一个子进程来触发写入外部文件的数据流管道。
import base64
import subprocess
def hello_pubsub(event, context):
if 'data' in event:
name = base64.b64decode(event['data']).decode('utf-8')
else:
name = 'World'
print('Hello {}!'.format(name))
var = subprocess.run(["python", "./defaultTrigger.py", "--input_topic", " projects/my_project/subscriptions/sub1" ,"--output_topic", "projects/my_project/topics/topic2"])
Ps:我的数据流管道从 sub1 读取并写入 topic2。
我的云功能是由 pubsub 触发的。
CompletedProcess(args=['python', '...', ... ] , 返回码=1
【问题讨论】:
-
Cloud Functions 是一个托管运行时,您无法执行此操作。您可能想查看 Cloud Run,它在许多方面类似于 Cloud Functions,但它运行您构建的容器。您可能可以做您在 Cloud Run 中要求的那种事情。
标签: python-3.x google-cloud-platform subprocess google-cloud-functions google-cloud-dataflow