-
Notifications
You must be signed in to change notification settings - Fork 35
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
Socket leak with large YAML test files #313
Comments
I've looked into this and have come up with a hypothesis: the test suite is being built ahead of time and each test is populated with an instance of A potential, working solution for this could be the following but it feels more like a hack than anything else. --- a/gabbi/httpclient.py
+++ b/gabbi/httpclient.py
@@ -51,6 +51,8 @@ class Http(urllib3.PoolManager):
headers = response.headers
headers['status'] = str(status)
headers['reason'] = reason
+
+ self.clear()
return headers, content
|
Good find. The main reason pool's aren't reused is so that each test can set its own requirements for hostname, verbosity, and cert validation. And the reason they don't go out of scope is because every test in a single yaml file is kept in memory for the duration of the suite, as this allows the back references ($RESPONSE, $HISTORY, etc). So if you're oriented towards big test suites you should keep that in mind as it might create some memory issues for you. The original design of gabbi (before Also, using PoolManager was a late addition. Earlier versions used httplib2, which is much simpler, but it looked like it was no longer being maintained, so a switch was made.
Thoughts? |
We could clear the pool, as I've done above, for a short-term solution whilst thinking about a better long-term solution. My initial thoughts are to utilise a shared HTTP pool somehow. |
I have a YAML file with nearly 2000 tests in it. When invoked from the command line, I run out of open file handles due to large amounts of sockets left open:
By default a Linux user has 1024 file handles:
Inspecting the open file handles:
The text was updated successfully, but these errors were encountered: