'TypeError: a coroutine was expected, got None

class Test():
    def send(self,dela,i):
        time.sleep(dela)
        print("process",i)
        return

    async def proc(self,dela):
        task=list()
        for i in range(5):
            task.append(asyncio.create_task(self.send(3,i)))
        res = await asyncio.gather(*task)
        print(res)
        return 

    def call(self):
        asyncio.run(self.proc(3))
        return "123"

obj=Test()
obj.call()

I want to run the send method in a for loop concurrently and dont want to wait for each iteration to be completed ,but in the end gather the tasks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source