Add retries to signer check
This commit is contained in:
parent
2320a6b39b
commit
05b1c94551
@ -1,4 +1,5 @@
|
|||||||
# standard imports
|
# standard imports
|
||||||
|
import time
|
||||||
import logging
|
import logging
|
||||||
from urllib.error import URLError
|
from urllib.error import URLError
|
||||||
|
|
||||||
@ -12,15 +13,25 @@ logg = logging.getLogger().getChild(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def health(*args, **kwargs):
|
def health(*args, **kwargs):
|
||||||
|
blocked = True
|
||||||
|
max_attempts = 5
|
||||||
conn = RPCConnection.connect(kwargs['config'].get('CIC_CHAIN_SPEC'), tag='signer')
|
conn = RPCConnection.connect(kwargs['config'].get('CIC_CHAIN_SPEC'), tag='signer')
|
||||||
try:
|
for i in range(max_attempts):
|
||||||
conn.do(sign_message(ZERO_ADDRESS, '0x2a'))
|
idx = i + 1
|
||||||
except FileNotFoundError:
|
logg.debug('attempt signer connection check {}/{}'.format(idx, max_attempts))
|
||||||
return False
|
try:
|
||||||
except ConnectionError:
|
conn.do(sign_message(ZERO_ADDRESS, '0x2a'))
|
||||||
return False
|
except FileNotFoundError:
|
||||||
except URLError:
|
pass
|
||||||
return False
|
except ConnectionError:
|
||||||
except JSONRPCException as e:
|
pass
|
||||||
pass
|
except URLError:
|
||||||
return True
|
pass
|
||||||
|
except JSONRPCException:
|
||||||
|
logg.debug('signer connection succeeded')
|
||||||
|
return True
|
||||||
|
|
||||||
|
if idx < max_attempts:
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user