| | |
| | | sk.send(socket_util.load_header(json.dumps({"type": "heart", "client_id": client_id}).encode('utf-8'))) |
| | | # print("心跳信息发送成功", client_id) |
| | | except Exception as e: |
| | | logging.error("错误") |
| | | print("心跳信息发送失败", _type, client_id) |
| | | logging.exception(e) |
| | | if _type == CLIENT_TYPE_TRADE: |
| | | if client_id in cls.trade_client_dict: |
| | | cls.trade_client_dict.pop(client_id) |
| | |
| | | sk = socket_util.create_socket("127.0.0.1", trade_client_server.SERVER_PORT) |
| | | if True: |
| | | sk.sendall(socket_util.load_header(json.dumps(root_data).encode("utf-8"))) |
| | | if blocking: |
| | | result_data, header_str = socket_util.recv_data(sk) |
| | | if result_data: |
| | | set_response(request_id,json.loads(result_data)) |
| | | try: |
| | | if blocking: |
| | | result_data, header_str = socket_util.recv_data(sk) |
| | | if result_data: |
| | | data_json = json.loads(result_data) |
| | | set_response(request_id, data_json["data"]) |
| | | finally: |
| | | sk.close() |
| | | else: |
| | | pipe_trade.send(json.dumps(root_data).encode("utf-8")) |
| | | async_log_util.info(hx_logger_trade_loop, "请求发送成功:request_id-{}", request_id) |