The following code outputs as follows:
1 sec delay, print \"1\",
1 sec delay, print \"2\",
1 sec delay, print \"1\",
1 sec delay, print \"2\"
To run the two functions simultaneously you can use gather. However, the results will be provided to you in the order you provide them. So for example if you do
results = await asyncio.gather(first(), second())
Then you will get [the result of first(), the result of second()]
back. If you want to do something whenever each one returns then you should use Tasks
explicitly and add callbacks.