diff options
author | Vilém Duha <vilda.novak@gmail.com> | 2019-09-02 14:50:06 +0300 |
---|---|---|
committer | Vilém Duha <vilda.novak@gmail.com> | 2019-09-02 14:50:06 +0300 |
commit | db4f7e2dc66d437b205f8097c2bdf9097b5c8834 (patch) | |
tree | f5657def06ae9fe5298c9f17fca164635662de96 /blenderkit/categories.py | |
parent | e529809cf6513748776a878338109ecf960d1326 (diff) |
BlenderKit: rerequests library
this library basically ensures that no server requests should fail if the token is after it's lifetime.
it refreshes token and re-tries the request in such cases.
Diffstat (limited to 'blenderkit/categories.py')
-rw-r--r-- | blenderkit/categories.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/blenderkit/categories.py b/blenderkit/categories.py index 6407b050..1d411499 100644 --- a/blenderkit/categories.py +++ b/blenderkit/categories.py @@ -22,8 +22,9 @@ if "bpy" in locals(): paths = reload(paths) utils = reload(utils) tasks_queue = reload(tasks_queue) + rerequests = reload(rerequests) else: - from blenderkit import paths, utils, tasks_queue + from blenderkit import paths, utils, tasks_queue, rerequests import requests import json @@ -114,7 +115,7 @@ def fetch_categories(API_key): categories_filepath = os.path.join(tempdir, 'categories.json') try: - r = requests.get(url, headers=headers) + r = rerequests.get(url, headers=headers) rdata = r.json() categories = rdata['results'] fix_category_counts(categories) |