From 1485b0a1863081573476381d5e54181ac2db21a5 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sun, 3 Dec 2023 23:20:29 +0100 Subject: [PATCH] No default Session --- wikidata_ext.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wikidata_ext.py b/wikidata_ext.py index 51a5fa4..3f0c26c 100644 --- a/wikidata_ext.py +++ b/wikidata_ext.py @@ -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)