Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Disconnect connection when garbage collected #268

Open
TheTechRobo opened this issue Apr 3, 2022 · 1 comment
Open

Proposal: Disconnect connection when garbage collected #268

TheTechRobo opened this issue Apr 3, 2022 · 1 comment
Labels
enhancement New feature or request not qualified The issue is not checked yet by the owners question Further information is requested

Comments

@TheTechRobo
Copy link

TheTechRobo commented Apr 3, 2022

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.

@TheTechRobo TheTechRobo added enhancement New feature or request not qualified The issue is not checked yet by the owners question Further information is requested labels Apr 3, 2022
@TheTechRobo
Copy link
Author

Sorry, I didn't see the "no feature requests" in the README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request not qualified The issue is not checked yet by the owners question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants