From 255bf72c128482a1abefce0498dec89c7b479fc4 Mon Sep 17 00:00:00 2001 From: nolash Date: Sun, 11 Jul 2021 15:10:57 +0200 Subject: [PATCH] Move conn constructor to loop method --- apps/cic-eth/cic_eth/runnable/daemons/dispatcher.py | 11 +++++++---- apps/contract-migration/reset.sh | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/cic-eth/cic_eth/runnable/daemons/dispatcher.py b/apps/cic-eth/cic_eth/runnable/daemons/dispatcher.py index 08a54185..252b507a 100644 --- a/apps/cic-eth/cic_eth/runnable/daemons/dispatcher.py +++ b/apps/cic-eth/cic_eth/runnable/daemons/dispatcher.py @@ -134,14 +134,18 @@ class DispatchSyncer: logg.info('processed {}'.format(k)) - def loop(self, w3, interval): + def loop(self, interval): while run: txs = {} typ = StatusBits.QUEUED utxs = get_upcoming_tx(self.chain_spec, typ) for k in utxs.keys(): txs[k] = utxs[k] - self.process(w3, txs) + try: + conn = RPCConnection.connect(self.chain_spec, 'default') + self.process(conn, txs) + except ConnectionError as e: + logg.error('connection to node failed: {}'.format(e)) if len(utxs) > 0: time.sleep(self.yield_delay) @@ -151,8 +155,7 @@ class DispatchSyncer: def main(): syncer = DispatchSyncer(chain_spec) - conn = RPCConnection.connect(chain_spec, 'default') - syncer.loop(conn, float(config.get('DISPATCHER_LOOP_INTERVAL'))) + syncer.loop(float(config.get('DISPATCHER_LOOP_INTERVAL'))) sys.exit(0) diff --git a/apps/contract-migration/reset.sh b/apps/contract-migration/reset.sh index cf8798fe..8c5f5b3b 100755 --- a/apps/contract-migration/reset.sh +++ b/apps/contract-migration/reset.sh @@ -137,6 +137,7 @@ else fi mkdir -p $CIC_DATA_DIR +>&2 echo using data dir $CIC_DATA_DIR for environment variable dump # this is consumed in downstream services to set environment variables cat << EOF > $CIC_DATA_DIR/.env