我有一个谷歌的云功能和内,我叫了两个外部的API(或URL),使用Pythonrequests
库,一个requests.get
和另一个requests.post
。请注意,这些API已通过Postman测试并可以使用。
在requests.get
正在下载的MP3文件,它是在云计算功能的工作,因为我能看到在云存储下载的文件:
download_url = "https://some.url.com/music.mp3"
resp = requests.get(download_url)
[get the resp.content, put to storage bucket]
除了存储在Cloud Storage中之外,我还将此mp3文件发送到Google Cloud Speech-to-Text API,并获得了转录的文本,我想将其发布到另一个URL。
[transcribe the audio using Speech-to-Text API, get the transcibed text]
data = { "download_url": download_url, "transcription": transcribed_text }
upload_api = https://another.url.com/api"
resp = requests.post(upload_api, data = data)
同样,转录工作正常,因为我打印/记录了文本并将其显示在Cloud Functions的View Logs控制台中。在requests.post
但是,我得到一个超时,还可以根据日志。
requests.post(upload_api, data = data, timeout=120)
我什至延长了超时设置,但这仍然会发生。这可能是什么解释?我是否想设置某个可能导致此问题的Google Cloud配置?
这是因为GCP云功能具有1分钟的超时时间,要修复此问题,必须在创建函数时声明超时限制
如果使用Gcloud CLI命令部署功能,则需要添加--timeout标志
例如
gcloud functions deploy FUNCTION_NAME --timeout=TIMEOUT FLAGS
如果您使用的是GCP控制台(Web UI),则需要按照此链接上的步骤进行操作
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句