How i call async function without await?

前端 未结 2 1951
Happy的楠姐
Happy的楠姐 2021-01-01 19:08

I have a controller action in aiohttp application.

async def handler_message(request):

    try:
        content = await request.json()
        perform_messa         


        
相关标签:
2条回答
  • 2021-01-01 19:18

    Other way would be to use ensure_future function:

    import asyncio
    
    async def handler_message(request):
    ...
    loop = asyncio.get_event_loop()
    loop.ensure_future(perform_message(x,y,z))
    ...
    
    0 讨论(0)
  • 2021-01-01 19:19

    One way would be to use create_task function:

    import asyncio
    
    async def handler_message(request):
        ...
        loop = asyncio.get_event_loop()
        loop.create_task(perform_message(x,y,z))
        ...
    
    0 讨论(0)
提交回复
热议问题