Skip to content

Instantly share code, notes, and snippets.

@jAlpedrinha
Created August 4, 2016 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jAlpedrinha/0ebef666d68f0c71245cd6e20dd006e8 to your computer and use it in GitHub Desktop.
Save jAlpedrinha/0ebef666d68f0c71245cd6e20dd006e8 to your computer and use it in GitHub Desktop.
Async loop example
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