import asyncio async def task_that_raise(): # If you return something here (instead of raising an exception), memory doesn't increase unboundedly raise Exception("hola") async def main(): task = asyncio.create_task(task_that_raise()) while True: try: await task except Exception: pass asyncio.run(main())