Skip to content

Instantly share code, notes, and snippets.

@mr-yoo
Created March 19, 2021 08:28
Show Gist options
  • Save mr-yoo/01316d87deaacecbb887647c8c46e2da to your computer and use it in GitHub Desktop.
Save mr-yoo/01316d87deaacecbb887647c8c46e2da to your computer and use it in GitHub Desktop.
import asyncio
async def A(q):
num1 = 3
num2 = await q.get()
if num1 < num2:
print("OK")
async def B(q):
num2 = 5
await q.put(num2)
loop = asyncio.get_event_loop()
q = asyncio.Queue(loop=loop)
a = A(q)
b = B(q)
loop.run_until_complete(asyncio.gather(a, b))
loop.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment