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
Too many open files #239
Comments
Where you using |
nope, all requests were reasonably plain requests.get / requests.post, I am still seeing a few in there
all but 4/5 of them are of the format
|
I'm a bit baffled by this, to be honest. |
Hah ill take another shot at reproducing it reliably, if I cant ill close |
I've seen this happening to me, but only when I'm using the async module w/ 200+ simultaneous connections. |
Hi, |
It may be problem of ulimit -n. Try with a higher value. |
"Too many open files" is the result of the bug caused by sockets staying in CLOSE_WAIT . |
@Tamiel how do we fix this? |
I will do more tests asap and try to fix . |
I've looked into it, and seems to be a problem with all libraries using httplib.HTTPSConnection. |
Posted an example here : |
I just encountered a very similar error using an async pool with only HTTP connections - I'm still investigating but passing a pool size to async.map makes the error reproduce quickly. |
Any fixes to this? This makes Requests unusable with gevent.. |
It's all about the |
Is it a urllib3 issue? Having to close these by ourselves isnt a great idea i feel. |
It's more of a general issue. We can keep the conversation here. |
Ok just to give you a perspective, we are trying to move from httplib2 to requests, and we dont see this issue with httplib2. So its not a general issue for sure. |
By general i mean that it's a very serious issue that effects everyone involved. |
so how do we solve this? we really want to use requests + slumber moving forward |
I'd love to know the answer to that. |
The leak appears to be due to the internal redirect handling, which causes new requests to be generated before the pending responses have been consumed. In testing acdha/requests@730c0e2 has an under-satisfying but effective fix simply by forcing each response to be consumed before continuing. This required changes in two places which makes me want to refactor the interface slightly but I'm out of time to continue currently. |
#399 has a fix which works well in my async load generator (https://github.com/acdha/webtoolbox/blob/master/bin/http_bench.py) with thousands of requests and a low fd ulimit |
I have run into the same issue when using async -- kludged a workaround by chunking requests and deleting responses / calling gc.collect |
I believe I was running into this today connecting to a licensed server that only allows 5 connections. Using async I could only GET 4 things before it paused for 60 seconds. Using the normal GET with consumption I could fetch about 150 things serially in under 40 seconds. Haven't made my kludge yet since I saw this issue. |
Just got this error while using ipython and got this message. This is just making each request one at a time, but I think I got something similar when using async.
Oddly, I think when using just the normal Python interpreter I get a "Max Retries Error" but I think that is another issue with me doing requests on all the same domain, but not sure. |
@polvoazul There's no way this is the same issue, which was originally reported in 2011, so I don't think reopening is correct. However, if you're running the current release of requests (2.4.3) and can reproduce the problem, opening a new issue would be correct. |
@Lukasa i need you help 。 i use eventlet + requests,that always create so many sock that can't identify protocol 。 my requests is 2.4.3, is eventlet + requests cause this problem? |
I'm sorry @mygoda, but it's impossible to know. If you aren't constraining the number of requests that can be outstanding at any one time then it's certainly possible, but that's an architectural problem outside the remit of requests. |
Having the same problem now, running 120 threads, cause 100000+ opened files, any solution right now? |
@mygoda you use awesome periods。 |
@1a1a11a What files do you have open? That'd be a useful first step to understanding this problem. |
@1a1a11a what version of requests are you using? What version of python? What operating system? Can we get any information? |
I am using request 2.9.1, python 3.4, ubuntu 14.04, basically I am writing a crawler using 30 threads with proxies to crawl some website. Currently I have adjusted the file limit per process to 655350, otherwise it will report error. |
I am still receiving the error "Failed to establish a new connection: [Errno 24] Too many open files" from requests.packages.urllib3.connection.VerifiedHTTPSConnection." I'm using Python 3.4, requests 2.11.1 and requests-futures 0.9.7. I appreciate requests-futures is a separate library, but it seems like the error is coming from requests. I'm attempting to make 180k asynchronous requests over SSL. I've divided those requests into segments of 1000, so I only move onto the next 1000 once all the future objects have been resolved. I'm running Ubuntu 16.04.2 and my default open files limit is 1024. It would be good to understand the underlying reason for this error. Does the requests library create an open file for each individual request? And if so, why? Is this a SSL certificate file? And does the requests library automatically close those open files when the future object is resolved? |
Requests opens many files. Some of those files are opened for certificates, but they are opened by OpenSSL and not by Requests, so those aren't maintained. Additionally, Requests will also open, if needed, the You will be best served by using a tool like |
I struggled with this issue as well and found that using |
I'm also frequently seeing this error when repeatedly calling |
What is |
A few hundred kb text |
Not a file object? |
No, I form a large query in memory. |
Are you running this code in multiple threads? |
No, single thread, posting to localhost |
It seems almost impossible for us to be leaking that many FDs then: we should be repeatedly using the same TCP connection or aggressively closing it. Want to check what your server is up to? |
I am having this problem. Python 2.7, requests 2.18.4, urllib3 1.22. |
I'm having the same problem on |
@mcobzarenco are you sure you are (implicitly) closing the underlying connection of the response? Simply returning the response will not close the connection. When reading response.content the data is actually read and after that the socket will not stay in CLOSE_WAIT. |
I am building a basic load generator and started running into file descriptor limits, I havent seen any documentation pertaining to how to release resources, so either I am doing it wrong and the docs need updated, or requests is leaking file descriptors somewhere (without support for keepalive I am slightly confused at why any files would be left open at all)
The text was updated successfully, but these errors were encountered: