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

"Too many open files" error #439

Open
ianbstewart opened this issue May 19, 2021 · 1 comment
Open

"Too many open files" error #439

ianbstewart opened this issue May 19, 2021 · 1 comment

Comments

@ianbstewart
Copy link

After using geocoder.osm for a few hundred queries, I get the same error over and over from geocoder:

ERROR - HTTPSConnectionPool(host='nominatim.openstreetmap.org', port=443): Max retries exceeded with url: /sea
rch?q=NYC&format=jsonv2&addressdetails=1&limit=1 (Caused by SSLError(OSError(24, 'Too many open files')))

I don't think that the problem is on my end. It seems like a weird version of rate limiting. I added a sleep function for 5 seconds between queries but that didn't change anything. How to fix this error?

@interDist
Copy link
Contributor

I was investigating a different warning, but I think the root cause is the same: Geocoder does not explicitly close the HTTP session it makes use of:

self.session = kwargs.get('session', requests.Session())

It is by design, since it can reuse a session created elsewhere. Even though I would expect it to close itself the session it creates on its own or at least clearly document this in the docs (the section “Using a Session” has no mention of the fact that Geocoder will create a session if one is not provided in the kwargs).

The solution is to explicitly close the session after you’ve retrieved the results:

    result = geocoder.osm( ... )
    result.session.close()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants