Last active
February 5, 2018 15:43
-
-
Save AlexanderOnbysh/e6346df4552fb84589194f8ddc89b459 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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