Add response on socket

This commit is contained in:
lash 2022-04-10 17:13:49 +00:00
parent 9cd89f4a83
commit dab50dadd1
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 15 additions and 9 deletions

View File

@ -99,9 +99,10 @@ signal.signal(signal.SIGTERM, ctrl.shutdown)
def main():
while True:
r = None
v = None
client_socket = None
try:
r = ctrl.get()
(client_socket, v) = ctrl.get()
except ClientGoneError:
break
except ClientBlockError:
@ -111,20 +112,25 @@ def main():
except NothingToDoError:
pass
if r == None:
if v == None:
ctrl.process(conn)
continue
result_data = None
r = 0 # no error
try:
tx_hash = queue_adapter.put(r.hex())
result_data = queue_adapter.put(v.hex())
except DuplicateTxError as e:
logg.error('tx already exists as {}'.format(e))
continue
logg.error('tx already exists: {}'.format(e))
r = 1
except ValueError as e:
logg.error('adapter rejected input {}: "{}"'.format(r.hex(), e))
logg.error('adapter rejected input {}: "{}"'.format(v.hex(), e))
continue
queue_adapter.enqueue(tx_hash)
if r == 0:
queue_adapter.enqueue(result_data)
ctrl.respond_put(client_socket, r, extra_data=result_data)
if __name__ == '__main__':

View File

@ -6,5 +6,5 @@ After=chaind-eth-sync@.service
[Service]
Environment="SESSION_ID=%i"
Environment="SESSION_RUNTIME_DIR=/run/user/%U/chaind/eth"
ExecStart=%h/.local/bin/chaind-eth-server -v --session-id %i
ExecStart=%h/.local/bin/chaind-eth-tasker -v --session-id %i
Restart=on-failure