mirror of
https://github.com/planetmint/planetmint.git
synced 2025-03-30 15:08:31 +00:00
improved connection error and termination handling
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
parent
4837522570
commit
b2c5a5297a
@ -69,5 +69,12 @@ class ABCI_RPC:
|
||||
"params": [encode_transaction(tx_dict)],
|
||||
"id": str(uuid4()),
|
||||
}
|
||||
# TODO: handle connection errors!
|
||||
return requests.post(endpoint, json=payload)
|
||||
try:
|
||||
response = requests.post(endpoint, json=payload)
|
||||
except requests.exceptions.ConnectionError as e:
|
||||
logger.error(f"Tendermint RCP Connection issue: {e}")
|
||||
raise e
|
||||
except Exception as e:
|
||||
logger.error(f"Tendermint RCP Connection issue: {e}")
|
||||
raise e
|
||||
return response
|
||||
|
@ -1,9 +1,11 @@
|
||||
from queue import Empty
|
||||
from collections import defaultdict
|
||||
import multiprocessing
|
||||
import logging
|
||||
|
||||
from planetmint.ipc.events import EventTypes, POISON_PILL
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Exchange:
|
||||
"""Dispatch events to subscribers."""
|
||||
@ -63,10 +65,13 @@ class Exchange:
|
||||
def run(self):
|
||||
"""Start the exchange"""
|
||||
self.started_queue.put("STARTED")
|
||||
|
||||
while True:
|
||||
event = self.publisher_queue.get()
|
||||
if event == POISON_PILL:
|
||||
return
|
||||
else:
|
||||
self.dispatch(event)
|
||||
try:
|
||||
while True:
|
||||
event = self.publisher_queue.get()
|
||||
if event == POISON_PILL:
|
||||
return
|
||||
else:
|
||||
self.dispatch(event)
|
||||
except Exception as e:
|
||||
logger.debug(f"Exchange Exception: {e}")
|
||||
|
||||
|
@ -104,9 +104,14 @@ class TransactionListApi(Resource):
|
||||
but this node only accepts transaction with higher \
|
||||
schema version number.",
|
||||
)
|
||||
status_code, message = ABCI_RPC().write_transaction(
|
||||
MODE_LIST, ABCI_RPC().tendermint_rpc_endpoint, MODE_COMMIT, tx_obj, mode
|
||||
)
|
||||
try:
|
||||
status_code, message = ABCI_RPC().write_transaction(
|
||||
MODE_LIST, ABCI_RPC().tendermint_rpc_endpoint, MODE_COMMIT, tx_obj, mode
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Tendermint RPC connection issue: {e}")
|
||||
status_code = 500
|
||||
message = { "detail": "Tendermint RPC connection error"}
|
||||
|
||||
if status_code == 202:
|
||||
response = jsonify(tx)
|
||||
|
Loading…
x
Reference in New Issue
Block a user