simplify accumulate task

This commit is contained in:
Victor Shyba 2019-05-13 13:34:49 -03:00
parent 7c4eb416d6
commit d024433d1b

View file

@ -199,13 +199,10 @@ class Node:
async def _accumulate_search_junction(self, search_queue: asyncio.Queue, async def _accumulate_search_junction(self, search_queue: asyncio.Queue,
result_queue: asyncio.Queue): result_queue: asyncio.Queue):
tasks = [] tasks = []
async def __start_producing_task(): try:
while True: while True:
blob_hash = await search_queue.get() blob_hash = await search_queue.get()
tasks.append(asyncio.create_task(self._value_producer(blob_hash, result_queue))) tasks.append(asyncio.create_task(self._value_producer(blob_hash, result_queue)))
tasks.append(asyncio.create_task(__start_producing_task()))
try:
await asyncio.wait(tasks)
finally: finally:
for task in tasks: for task in tasks:
task.cancel() task.cancel()