Can or How to use Python asyncio on Google Cloud Functions?

后端 未结 1 1853
旧时难觅i
旧时难觅i 2021-01-06 11:30

Is it possible to use Python\'s asyncio on Google Cloud Functions?

async def handle_someting():
    # do something
    some = await aiofunc()

#         


        
相关标签:
1条回答
  • 2021-01-06 11:38

    Sure, you just need to run the async functions from your main deployed function (here, you would deploy the test function):

    import asyncio
    
    async def foo():
        return 'Asynchronicity!'
    
    async def bar():
        return await foo()
    
    def test(request):
        return asyncio.run(bar())
    
    0 讨论(0)
提交回复
热议问题