import asyncio import time def scountdown(n : int, name : str|None) -> None: while n > 0: if name is not None: print(name,n) else: print(n) time.sleep(1) n -= 1 scountdown(3, 'sync 3') scountdown(4, 'sync 4') async def acountdown(n : int, name : str|None) -> None: while n > 0: if name is not None: print(name,n) else: print(n) await asyncio.sleep(1) n -= 1 asyncio.run(acountdown(3, 'async 3')) asyncio.run(acountdown(4, 'async 4')) async def both() -> None: await asyncio.gather( acountdown(3, 'async 3b'), acountdown(4, 'async 4b'), acountdown(4, 'async 4b'), acountdown(4, 'async 4b'), acountdown(4, 'async 4b'), acountdown(4, 'async 4b'), ) asyncio.run(both())