Sag*_*nol 5 python python-asyncio google-cloud-platform google-cloud-functions
是否可以asyncio在 Google Cloud Functions 上使用 Python ?
async def handle_someting():
# do something
some = await aiofunc()
# Do I need the code below?
loop = asyncio.get_event_loop()
loop.run_until_complete(handle_someting())
loop.close()
Run Code Online (Sandbox Code Playgroud)
当然,您只需要从主要部署的函数中运行异步函数(在这里,您将部署该test函数):
import asyncio
async def foo():
return 'Asynchronicity!'
async def bar():
return await foo()
def test(request):
return asyncio.run(bar())
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2846 次 |
| 最近记录: |