I have a slow function call early in the run, which returns a value I do not use until much later. I do not want to await this function when I first call it.
# run start
asyncio.get_event_loop().create_task(slow_function_wrapper())
async def slow_function_wrapper(self):
self.slow_value = await slow_function()
...
# later in the code
async def get_slow_value(self):
if iscoroutine(self.slow_value): #if the call still didn't finish, await it
await self.slow_value
return self.slow_value
my issue is, this seems to cause a memory leak. there's some reference still saved to the task, so even when it completes it does not clear it from memory.
Is there a standard way of not-awaiting async function? or clearing the reference once it's done?
This is python 3.7