Relative Content

Tag Archive for pythongarbage-collection

Can explicitly invoking the garbage collector in Python have side effects in this case?

can anyone help me with this?
When I call the heal_client method, and gc.collect() is executed, it successfully closes my database connection (just what I need). Is there something wrong with this approach, specifically with calling gc.collect() ?
(This code is part of a larger context involving asyncio and other libraries that got me to this point. It is expected that this method should almost never be called, but it has to be done because I have no other way to close the client and it is a long-running program.)
In conclusion, this approach seems to solve my problem, but I want to know if there might be a side effect that I am not seeing.