1
0

No default Session

This commit is contained in:
Jon Michael Aanes 2023-12-03 23:20:29 +01:00
parent 1d9715a9bf
commit 1485b0a186

View File

@ -6,7 +6,7 @@ import requests
import json
import logging
REQUEST_SESSION = requests.Session()
REQUEST_SESSION = None # TODO?
def concept_uri(obj):
assert isinstance(obj, wikidata.entity.Entity), obj
@ -33,6 +33,7 @@ def fmt_triple_value(obj, prefer_obj = False):
@ratelimit.sleep_and_retry
def fetch_by_url(url, headers):
logging.debug('Fetching: %s', url)
assert REQUEST_SESSION is not None, 'REQUEST_SESSION must be set, before calling fetch_by_url'
response = REQUEST_SESSION.get(url, headers = headers)
if response.status_code != 200:
logging.error('Got %s error message: %s', response.status_code, response.text)