Mar-13-2019, 03:28 PM
Python 3.7.2
I created an event loop, run the task in it, but one of the objects wasn't deleted. After closing the event loop, I forced the garbage collection and in the debugger I finally got into the __del__ method of my object:
Why?
I created an event loop, run the task in it, but one of the objects wasn't deleted. After closing the event loop, I forced the garbage collection and in the debugger I finally got into the __del__ method of my object:
def __call__(self):
loop = self._get_event_loop()
try:
loop.run_until_complete(self._create_workers())
except Exception as err:
print('Operation sucessfully failed!)
raise err
finally:
#close the created event loop
loop.close()
gc.collect() #in this place object, created in event loop finally deleteIf I place the call gc.collect() before closing the event loop, then the object will remain alive (I don’t get to the __del__ method and my data is not written to the database).Why?
