fix: while 循环做card_door_authority的补偿机制2

This commit is contained in:
caoqianming 2023-05-08 18:14:57 +08:00
parent 8d3d1934b7
commit a395817028
1 changed files with 22 additions and 10 deletions

View File

@ -193,18 +193,30 @@ class HrmService:
"cardPrivilegeDetails": details "cardPrivilegeDetails": details
} }
ind = 0 ind = 0
exception = None
while ind < 6: while ind < 6:
time.sleep(5) time.sleep(6)
is_ok, res = dhClient.request(**dhapis['card_door_authority'], json=json_data, raise_exception=False) try:
if is_ok == 'success': dhClient.request(**dhapis['card_door_authority'], json=json_data)
break exception = None
elif is_ok == 'fail' and '44999999' in res['code']: except Exception as e:
exception = e
ind = ind + 1 ind = ind + 1
continue if exception:
elif is_ok == 'fail': raise exception
raise ParseError(**res) # while ind < 6:
elif is_ok == 'error': # time.sleep(5)
raise APIException(**DH_REQUEST_ERROR) # is_ok, res = dhClient.request(**dhapis['card_door_authority'], json=json_data, raise_exception=False)
# if is_ok == 'success':
# break
# elif is_ok == 'fail' and '44999999' in res['code']:
# if ind
# ind = ind + 1
# continue
# elif is_ok == 'fail':
# raise ParseError(**res)
# elif is_ok == 'error':
# raise APIException(**DH_REQUEST_ERROR)
cls.save(ep, data={'dh_dchannels': dh_dchannels}) cls.save(ep, data={'dh_dchannels': dh_dchannels})
return dh_dchannels return dh_dchannels