Skip to content

Instantly share code, notes, and snippets.

@AlexanderOnbysh
Last active February 5, 2018 15:43
Show Gist options
  • Save AlexanderOnbysh/e6346df4552fb84589194f8ddc89b459 to your computer and use it in GitHub Desktop.
Save AlexanderOnbysh/e6346df4552fb84589194f8ddc89b459 to your computer and use it in GitHub Desktop.
async def producer(queue: Queue):
for i in range(10):
await asyncio.sleep(5)
await queue.put(i)
await queue.put(None)
async def consumer(queue: Queue):
while True:
value = await queue.get()
if not value:
break
print(f'Get value: {value}')
async def run():
queue = Queue()
loop = asyncio.get_event_loop()
loop.create_task(fill_queue(queue))
await consule_queue(queue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment