I have a list of objects, and for each object, I need to do some async work on it. I am not sure if I construct it right:
def run(tasks):
async def async_wrapper():
async def update_task():
updated_task = await task_manager.async_get_task_status(session, task)
# do some works with updated_task
workers = []
resolver = aiohttp.AsyncResolver()
connector = aiohttp.TCPConnector(resolver=resolver, family=socket.AF_INET)
async with aiohttp.ClientSession(connector=connector) as session:
for local_task in tasks: # tasks is a list of object
await update_ocr_task()
loop = asyncio.get_event_loop()
loop.run_until_complete(aysnc_wrapper())
I think the for loop is sync and will totally block the progress, am I right? If I am, how to construct it?