Oct-18-2022, 09:53 PM
(This post was last modified: Oct-18-2022, 09:53 PM by deanhystad.)
What is this supposed to do?
Are you trying to do something like this where the csv reader provides arguments for the coroutine?
tasks = (asyncio.create_task([row[0] for row in csv.reader(d)]))According to the documentation, the first argument to asyncio.create_task() is the coroutine.
Are you trying to do something like this where the csv reader provides arguments for the coroutine?
import asyncio # Emulate (very loosely) a csv reader csvReader = [[i] for i in range(1, 10)] async def coroutine(value=3): await asyncio.sleep(1) return value**2 async def main(): tasks = (asyncio.create_task(coroutine(row[0])) for row in csvReader) results = await asyncio.gather(*tasks, return_exceptions=True) print(results) asyncio.run(main())