Looks like if decorated function raises error here, FunctionThread.running would not be set to False, and afterwards it won't be poped from list running_functions until the program ends. This can be a memory leak
This code can be a fix:
def run(self):
self.running = True
now = datetime.now()
try:
if asyncio.iscoroutinefunction(self.function):
asyncio.run(self.function(now))
else:
self.function(now)
finally:
self.running = False
Looks like if decorated function raises error here,
FunctionThread.runningwould not be set toFalse, and afterwards it won't be poped from listrunning_functionsuntil the program ends. This can be a memory leakThis code can be a fix: