Commit 378fc048 by 刘豪

digikey update

parent e1ce57fb
Showing with 2 additions and 1 deletions
...@@ -116,13 +116,14 @@ class DGTokenCrawler(token_lib.BaseTokenCrawler): ...@@ -116,13 +116,14 @@ class DGTokenCrawler(token_lib.BaseTokenCrawler):
} }
resp = requests.post(p_url, headers=p_headers, data=p_data, timeout=60) resp = requests.post(p_url, headers=p_headers, data=p_data, timeout=60)
self.logger.info("digikey token 返回内容:{}".format(resp.text)) self.logger.info("digikey token 返回内容:{}".format(resp.text))
token_json = resp.json() token_json = json.loads(resp.text)
if not token_json.get('access_token', ''): if not token_json.get('access_token', ''):
self.logger.info("返回内容异常,休眠30s") self.logger.info("返回内容异常,休眠30s")
time.sleep(30) time.sleep(30)
# 说明digikey接口内容返回异常,尝试再次获取,不确定refresh_token经过一次请求后返回内容异常时是否失效,需观察,如果失效的话,那么重试就没有任何意义了 # 说明digikey接口内容返回异常,尝试再次获取,不确定refresh_token经过一次请求后返回内容异常时是否失效,需观察,如果失效的话,那么重试就没有任何意义了
self.get_token_by_refresh_token(count) self.get_token_by_refresh_token(count)
else: else:
self.logger.info("返回内容正常")
return token_json return token_json
except Exception: except Exception:
# 通常是超时了,休眠1分钟后重新尝试获取,但是超时的报错不确定refresh_token是否就会因此失效,所以还得观察 # 通常是超时了,休眠1分钟后重新尝试获取,但是超时的报错不确定refresh_token是否就会因此失效,所以还得观察
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment