I have a wrapper function which might run a courutine several times:
async def _request_wraper(self, courutine, attempts=5):
for i in range(1, attempts):
try:
task_result = await asyncio.ensure_future(courutine)
return task_result
except SOME_ERRORS:
do_smth()
continue
Corutine might be created from differect async func, which may accept diferent number of necessary/unnecessary arguments. When I have a second loop iteration, I am getting error --> cannot reuse already awaited coroutine
I have tried to make a copy of courutine, but it is not possible with methods copy and deepcopy. What could be possible solution to run corutine twice?