def __init__(self): generate_zmq_certificates_if_needed() self._socket = None # initialize ZMQ stuff: context = zmq.Context() logger.debug("Connecting to server...") socket = context.socket(zmq.REQ) if flags.ZMQ_HAS_CURVE: # public, secret = zmq.curve_keypair() client_keys = zmq.curve_keypair() socket.curve_publickey = client_keys[0] socket.curve_secretkey = client_keys[1] # The client must know the server's public key to make a CURVE # connection. public, _ = get_backend_certificates() socket.curve_serverkey = public socket.setsockopt(zmq.RCVTIMEO, 1000) socket.setsockopt(zmq.LINGER, 0) # Terminate early socket.connect(self.SERVER) self._socket = socket self._ping_at = 0 self.online = False self._call_queue = Queue.Queue() self._worker_caller = threading.Thread(target=self._worker)
def __init__(self): """ Initialize the backend proxy. """ generate_zmq_certificates_if_needed() self._do_work = threading.Event() self._work_lock = threading.Lock() self._connection = ZmqREQConnection(self.SERVER, self._set_online) self._heartbeat = TimerTask(self._ping, delay=self.PING_INTERVAL) self._ping_event = threading.Event() self.online = False self.settings = Settings()