Joseph Michael Pesch
VP Programming

Python Async without Await

by 19. May 2019 16:26

import asyncio
import time
 
async def px(x):
    time.sleep(5)
    print(x + ': ' + str(time.time()))
 
async def main():
    x = px('x')
    print("main1")
    y = px('y')
    print("main2")
    asyncio.ensure_future(y)
    asyncio.ensure_future(x)
 
asyncio.run(
    main())
    
input()

Tags:

Python

Comments are closed