[Tutor] Adding tasks periodically to asyncio.get_event_loop().run_forever()
An Nguyen
an at linux.com
Mon May 30 05:23:58 EDT 2016
Hello all,
I have a question related to AsyncIO. I have a while True: loop that
executes a list of tasks asynchronously every 10 seconds.
while True:
> loop = asyncio.get_event_loop()
> tasks = [ ]
> for arg in args:
> tasks.append(asyncio.ensure_future(my_coroutine(arg)))
> results = [ ]
> results = loop.run_until_complete(gather(*tasks))
> print(results)
> sleep(10)
>
Now how can I achieve the same outcome with loop.run_forever()?
What I want to achieve is to have a loop.run_forever() in my main(). Then
periodically, a list of tasks will be added to that event_loop for
execution.
Please enlighten me.
Thank you.
An.
More information about the Tutor
mailing list