def __init__(self, machine=None): try: self.config_man = ConfigManager() self.configure(machine) self.host, self.port = self.get_server_configs() self.address = zmqc.get_tcp_address(self.host, self.port) self.ctx = zmq.Context(io_threads=1) self.socket = zmqc.init_server(self.ctx, self.address) except Exception as e: print(str(e)) self.terminate()
clasifications.append(cl) result_dict = {} result_dict["result"] = clasifications result_dict["message"] = "OK" # print(result_dict) socket.send_json(result_dict) except Exception as e: result_dict = {} result_dict["result"] = [] result_dict["message"] = str(e) socket.send_json(result_dict) if __name__ == '__main__': socket = None try: host = CarConfig.crcl["host"] port = CarConfig.crcl["port"] ctx = zmq.Context(io_threads=1) tcp_address = zmq_comm.get_tcp_address(host, port) socket = zmq_comm.init_server(ctx, tcp_address) handle_requests(socket) except Exception as e: print(str(e)) finally: if socket is not None: print("Closing the socket properly..") socket.close()