aboutsummaryrefslogtreecommitdiffstats
path: root/python/experiments/test_async.py
blob: 8a9fca385860b3fa1d0dcbe50e6d55498b766cae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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()

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(asyncio.gather(pomme(), poire()))