Mar-21-2019, 02:28 PM
(This post was last modified: Mar-21-2019, 02:28 PM by AlekseyPython.)
Python 3.5
Initially, I launched several coroutine in ordered stages (which in the coroutine contain their tasks):
How I can do it?
Initially, I launched several coroutine in ordered stages (which in the coroutine contain their tasks):
async def _create_workers(self): scheme = get_scheme() for stage in scheme.get_next_stage(): await asyncio.gather(*stage) loop = asyncio.get_event_loop() loop.run_until_complete(self._create_workers())But in the process of work, it became known that one of the coroutine doesn't have time to done with its tasks, and I want to add copies of it. I analyze the load from one of the coroutine ('main'- coroutine), which adds data for processing. But if I create new task I have to wait for the new coroutine to complete:
new_task = asyncio.ensure_future(slow_coro()) await new_taskBut I don’t want to stop the execution flow 'main'- coroutine for waiting! I just want to add it to the current stage and so that the processing stage will finish only when the new coroutine is also completed.
How I can do it?