Skip to content
Snippets Groups Projects
Commit fb1efdef authored by Hang's avatar Hang
Browse files

fast push

parent 4b775c94
No related branches found
No related tags found
1 merge request!10MP3 Log Version Ready
......@@ -640,14 +640,11 @@ def client_handler(conn, SELF_NODE):
gprint(f'[server_handler] accounts_map: '
f'\n{json.dumps(accounts_map, default=lambda x: x.__dict__)}')
ret_value = reformat_return_value(ret_value)
ret_value = reformat_return_value(ret_value, operation)
if 'ABORT' in ret_value:
broadcast_msg(format_operation_and_timestamp_json('ABORT', timestamp), connect_info)
abort(SELF_NODE, timestamp)
if operation.startswith('BALANCE'):
account_name = operation.split()[1]
ret_value = f'{account_name} = {ret_value}'
send_msg_to_socket(ret_value, conn)
except Exception as e:
rprint(f"[ERROR] client_handler error:{e.__class__.__name__}.{e}.{traceback.format_exc()}")
......@@ -658,7 +655,7 @@ def client_handler(conn, SELF_NODE):
# client_send_socket.close()
def reformat_return_value(ret_value):
def reformat_return_value(ret_value, operation):
if isinstance(ret_value, bool):
if ret_value:
return 'True'
......@@ -667,6 +664,8 @@ def reformat_return_value(ret_value):
elif isinstance(ret_value, str):
return ret_value
elif isinstance(ret_value, int):
account_name = operation.split()[1]
ret_value = f'{account_name} = {ret_value}'
return str(ret_value)
elif ret_value == 'NOT FOUND, ABORTED':
return ret_value
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment