use requests session

This commit is contained in:
j 2019-08-02 14:23:07 +02:00
parent 23a641189c
commit e78519998d

View file

@ -16,6 +16,7 @@ from six import PY2
try:
import requests
USE_REQUESTS = True
requests_session = requests.Session()
except:
USE_REQUESTS = False
@ -101,7 +102,7 @@ def read_url(url, data=None, headers=None, timeout=cache_timeout, valid=None, un
url_headers = {}
if not result:
if USE_REQUESTS:
r = requests.get(url, headers=headers)
r = requests_session.get(url, headers=headers)
for key in r.headers:
url_headers[key.lower()] = r.headers[key]
result = r.content