Created
August 4, 2016 15:13
-
-
Save jAlpedrinha/0ebef666d68f0c71245cd6e20dd006e8 to your computer and use it in GitHub Desktop.
Async loop example
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
import asyncio | |
container_list = ['a', 'b', 'c'] | |
async def job(container_id): | |
while True: | |
print("I'll do stuff with this container", container_id) | |
await asyncio.sleep(1) | |
loop = asyncio.get_event_loop() | |
for container_id in container_list: | |
asyncio.ensure_future(job(container), loop = loop) | |
loop.run_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment