프로젝트

일반

사용자정보

Actions

코루틴

소스코드

import asyncio

async def make_americano():
    print("Americano Start")
    await asyncio.sleep(3)
    print("Americano End")

async def make_latte():
    print("Latte Start")
    await asyncio.sleep(5)
    print("Latte End")

async def main():
    coro1 = make_americano()
    coro2 = make_latte()
    await asyncio.gather(coro1, coro2)

print("Main Start")
asyncio.run(main())
print("Main End")

결과

Main Start
Americano Start
Latte Start
Americano End
Latte End
Main End

이태훈이(가) 10달 전에 변경 · 1 revisions