'how to execute 2 async functions in sequence without blocking execution

I am trying to run 2 function asynchronously, one after another, but at the same not block code execution that follows. This is my code:

def someFunction:

    dataFromCallingContext = "data created in the calling function"
    alsoDataFromCallingContext = "also data created in the calling function"

    loop = asyncio.get_event_loop()
    asyncCode = asyncio.gather(Gateway.delete_gateways(dataFromCallingContext), Gateway.set_status_for_index("available", alsoDataFromCallingContext ))
    results = loop.run_until_complete(asyncCode)
    loop.close()
    #run the code below immediately and do not wait for gather to finish

The code deletes what is represented as gateway, and after it is done, it sets the status "available" to the correct flag. Gateway.delete_gateways takes a very long time

If run, this returns an error saying that 'Gateway.delete_gateways' and also 'Gateway.set_status_for_index' was never awaited, but I do not want it to be awaited. I want the code that follows to continue executing without blocking. What is the correct syntax?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source