Skip to content

Commit

Permalink
handle exception for long running task
Browse files Browse the repository at this point in the history
  • Loading branch information
magicalne committed Apr 18, 2022
1 parent b58684a commit b33e9e2
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions agent/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,19 +305,30 @@ def run(self):
one_ckb = 100_000_000
if DISABLE_CUSTODIAN_STATS not in os.environ:
logging.info("Loading custodian stats")
CustodianStats = get_custodian(self.ckb_indexer_url,
self.gw_config,
LastBlockDetail["blocknumber"])
try:
CustodianStats = get_custodian(
self.ckb_indexer_url, self.gw_config,
LastBlockDetail["blocknumber"])
except:
logging.error("Failed to get custodian stats")
logging.info("Loading deposit stats")
DepositCount, DepositCapacity = get_gw_stat_by_lock(
"deposit_lock", self.gw_rpc, LastBlockHash["last_block_hash"],
self.ckb_rpc, self.gw_config)
DepositCapacity = DepositCapacity / one_ckb
try:
DepositCount, DepositCapacity = get_gw_stat_by_lock(
"deposit_lock", self.gw_rpc,
LastBlockHash["last_block_hash"], self.ckb_rpc,
self.gw_config)
DepositCapacity = DepositCapacity / one_ckb
except:
logging.error("Failed to get deposit stats")
logging.info("Loading withdrawal stats")
WithdrawalCount, WithdrawalCapacity = get_gw_stat_by_lock(
"withdrawal_lock", self.gw_rpc,
LastBlockHash["last_block_hash"], self.ckb_rpc, self.gw_config)
WithdrawalCapacity = WithdrawalCapacity / one_ckb
try:
WithdrawalCount, WithdrawalCapacity = get_gw_stat_by_lock(
"withdrawal_lock", self.gw_rpc,
LastBlockHash["last_block_hash"], self.ckb_rpc,
self.gw_config)
WithdrawalCapacity = WithdrawalCapacity / one_ckb
except:
loggint.error("Failed to get withdrawal stats")


job = JobThread()
Expand Down

0 comments on commit b33e9e2

Please sign in to comment.