Proposal: Disconnect connection when garbage collected #268
Labels
enhancement
New feature or request
not qualified
The issue is not checked yet by the owners
question
Further information is requested
Is your feature request related to a problem? Please describe.
In my program, I didn't know that you need to call
conn.disconnect()
when you are finished with a connection, causing me to frequently hit the "Too many open files" error (I opened too many connections to the RethinkDB server).Describe the solution you'd like
I believe that in classes there is the
__del__
function, called when the object is freed. Alternatively, there's also the weakref.finalize function (example). Using this, we could disconnect when the connection is garbage collected. Finally,r.connect
could be turned into a context manager, but that is a breaking change.Note that I'm not familiar with any of RethinkDB's code, so please tell me if this would have unintended side effects or backwards incompatibility. I'm also not fully sure if this solution would work, so correct me if I'm wrong.
Describe alternatives you've considered
We could add something like "Make sure to disconnect when you're done." to the ten-minute guide. Right now it does not mention disconnecting at all.
The text was updated successfully, but these errors were encountered: