lukaskubis / darkskylib

Python wrapper for the Dark Sky API
https://pypi.org/project/darkskylib/
MIT License
113 stars 23 forks source link

Reuse requests session between calls #18

Open kvelakur opened 4 years ago

kvelakur commented 4 years ago

Turning on logs for urllib3 indicates that darkskylib does not re-use the HTTP session between calls to the darksky server:

2019-11-06 13:32:20,518 18047-140558302398272 urllib3.connectionpool [connectionpool.py:959] : DEBUG: Starting new HTTPS connection (1): api.darksky.net:443 2019-11-06 13:32:20,865 18047-140558302398272 urllib3.connectionpool [connectionpool.py:437] : DEBUG: https://api.darksky.net:443 "GET /forecast/<api_key>/53.569008,-2.193415,2019-11-06T00:00:00+00:00?exclude=currently%2Cminutely%2Cdaily%2Calerts%2Cflags&lang=en&units=si HTTP/1.1" 200 None 2019-11-06 13:32:20,892 18047-140558302398272 urllib3.connectionpool [connectionpool.py:959] : DEBUG: Starting new HTTPS connection (1): api.darksky.net:443 2019-11-06 13:32:21,197 18047-140558302398272 urllib3.connectionpool [connectionpool.py:437] : DEBUG: https://api.darksky.net:443 "GET /forecast/<api_key>/53.575094,-2.08528,2019-11-06T00:00:00+00:00?exclude=currently%2Cminutely%2Cdaily%2Calerts%2Cflags&lang=en&units=si HTTP/1.1" 200 None 2019-11-06 13:32:21,221 18047-140558302398272 urllib3.connectionpool [connectionpool.py:959] : DEBUG: Starting new HTTPS connection (1): api.darksky.net:443 2019-11-06 13:32:21,418 18047-140558302398272 urllib3.connectionpool [connectionpool.py:437] : DEBUG: https://api.darksky.net:443 "GET /forecast/<api_key>/53.574674,-2.139347,2019-11-06T00:00:00+00:00?exclude=currently%2Cminutely%2Cdaily%2Calerts%2Cflags&lang=en&units=si HTTP/1.1" 200 None 2019-11-06 13:32:21,439 18047-140558302398272 urllib3.connectionpool [connectionpool.py:959] : DEBUG: Starting new HTTPS connection (1): api.darksky.net:443 2019-11-06 13:32:21,706 18047-140558302398272 urllib3.connectionpool [connectionpool.py:437] : DEBUG: https://api.darksky.net:443 "GET /forecast/<api_key>/53.556223,-2.178783,2019-11-06T00:00:00+00:00?exclude=currently%2Cminutely%2Cdaily%2Calerts%2Cflags&lang=en&units=si HTTP/1.1" 200 None

Is it possible to allow reuse of HTTP connections in darkskylib?

lukaskubis commented 4 years ago

Will investigate whether something like this would make sense or not.