add try/catch to json parse func
rest_client认为每个返回都可解为json,在处理alpaca的撤单操作时报错
This commit is contained in:
parent
eb691525fc
commit
04b0da5ce5
@ -268,9 +268,12 @@ class RestClient(object):
|
|||||||
request.response = response
|
request.response = response
|
||||||
status_code = response.status_code
|
status_code = response.status_code
|
||||||
if status_code // 100 == 2: # 2xx都算成功,尽管交易所都用200
|
if status_code // 100 == 2: # 2xx都算成功,尽管交易所都用200
|
||||||
jsonBody = response.json()
|
try:
|
||||||
request.callback(jsonBody, request)
|
jsonBody = response.json()
|
||||||
request.status = RequestStatus.success
|
request.callback(jsonBody, request)
|
||||||
|
request.status = RequestStatus.success
|
||||||
|
except:
|
||||||
|
print("not json body from request, check body: ",response.text)
|
||||||
else:
|
else:
|
||||||
request.status = RequestStatus.failed
|
request.status = RequestStatus.failed
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user