import asyncio async def pomme(): while True: await asyncio.sleep(1) print("pomme") async def poire(): while True: await asyncio.sleep(5) print("poire") async def main(): while True: await pomme() await poire() async def ping(msg): if msg > 5: return print("ping got:", msg) await asyncio.sleep(1) msg += 1 await pong(msg) async def pong(msg): if msg > 5: return print("pong got:", msg) await asyncio.sleep(1) msg += 1 await ping(msg) if __name__ == "__main__": loop = asyncio.get_event_loop() loop.run_until_complete(asyncio.gather(ping(1), pomme(), poire()))