| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Tests look great! A few suggestions.
Sorry, something went wrong.
A single common cleanup point at the end makes it much less likely to accidentally re-introduce an open socket leak.
|
@tswast Another thought - since the cleanup only happens if the user calls .close(), we should probably update our code samples to include the client.close() line at the end. Otherwise I presume that many users will simply forget or not know about this. |
Sorry, something went wrong.
|
I'm working on a proposal to add close() to all clients and make clients act as a context manager. Once this is done, we'll likely need to update our sample rubric to account for this. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes #9790.
This PR fixes the client leaking open sockets by adding a close() method to the client for cleaning up after itself. It also fixes a similar leak in IPython magics - even if bqstorage client is used - when cell magic is run.
How to test
Run both code samples from the issue description, i.e. the one using magics, and the other one using a regular BigQuery client. In both cases the number of open connections at the end should be the same as at the beginning, meaning that no connections (sockets) are leaked.
Misc.
The magics._cell_magic() needs refactoring, it's very long and several helper methods should be extracted from it. But that's out of this PR's scope.
PR checklist