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

Support for max_retries when making call from requests #381

Closed
Monal5031 opened this issue Aug 31, 2021 · 4 comments
Closed

Support for max_retries when making call from requests #381

Monal5031 opened this issue Aug 31, 2021 · 4 comments
Milestone

Comments

@Monal5031
Copy link

Monal5031 commented Aug 31, 2021

I was using pyowm when I came across this error:

[ERROR] InvalidSSLCertificateError: HTTPSConnectionPool(host='api.openweathermap.org', port=443): 

Max retries exceeded with url: /data/2.5/weather?<ids> 

(Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1091)')))

After looking through the code I found there is no option in config to set a max_retries.

I was hoping this support could be added by allowing a max_retries param in any config and using it to create a new Session/Adapter for requests before making the API calls here:

https://github.com/csparpa/pyowm/blob/master/pyowm/commons/http_client.py#L131

@csparpa csparpa added this to the 3.3.0 milestone Aug 31, 2021
@csparpa
Copy link
Owner

csparpa commented Aug 31, 2021

Good catch! Thanks, this will fit into the next release :)

Would you like to submit a PR yourself for this ?

@Monal5031
Copy link
Author

I can work on it @csparpa , although won't be able to complete it soon (I hope that's okay).

If someone else wishes to work on this, please let me know.

csparpa added a commit that referenced this issue Sep 4, 2021
@csparpa
Copy link
Owner

csparpa commented Sep 4, 2021

Never mind @Monal5031 , I've submitted e3832d1 which should do the trick

By default, PyOWM will continue to apply infinite retries in calling the OWM API, but if you need to limit the number of calls this can be done via the configuration dict

By the way, in order to fix the InvalidSSLCertificateError you were getting, try to set "verify_ssl_certs": False in the config dict

@csparpa csparpa closed this as completed Sep 4, 2021
@Monal5031
Copy link
Author

Monal5031 commented Sep 7, 2021

Thanks @csparpa for fixing the issue so fast and also for the suggestion I'll try that (I really don't want to disable SSL verification) :)

@csparpa csparpa mentioned this issue Feb 14, 2022
csparpa added a commit that referenced this issue Feb 14, 2022
# New features
[380](#380) Implemented [National Weather Alerts](https://openweathermap.org/api/one-call-api#listsource) support
[376](#376) Now PyOWM uses SQLite instead of files to internally store city data. `CityIDRegistry` interface has changed but in a retrocompatible way


# Chores
[381](#381) Now it is possible to specify how many times to retry an API call


# Bugfixes
[379](#379) Experimental fix for `404` errors on Agromonitor API satellite image search 
[387](#387) Fixed lat/lon swap bug on Airpollution API
[389](#389) Fixed wrong city name in City ID database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants