def transmit(self, frame): """ Convert a frame object to a frame string and transmit to the server. :param Frame frame: the Frame object to transmit """ with self.__listeners_change_condition: listeners = sorted(self.listeners.items()) for (_, listener) in listeners: if not listener: continue try: listener.on_send(frame) except AttributeError: continue if frame.cmd == CMD_DISCONNECT and HDR_RECEIPT in frame.headers: self.__disconnect_receipt = frame.headers[HDR_RECEIPT] lines = utils.convert_frame(frame) packed_frame = pack(lines) if log.isEnabledFor(logging.DEBUG): log.debug("Sending frame: %s", utils.clean_lines(lines)) else: log.info("Sending frame: %r", frame.cmd or "heartbeat") self.send(packed_frame)
def transmit(self, frame): """ Convert a frame object to a frame string and transmit to the server. :param frame: the Frame object to transmit """ for listener in self.listeners.values(): if not listener: continue try: listener.on_send(frame) except AttributeError: continue lines = utils.convert_frame_to_lines(frame) packed_frame = pack(lines) if log.isEnabledFor(logging.DEBUG): log.debug("Sending frame %s", lines) else: log.info("Sending frame cmd=%r headers=%r", frame.cmd, frame.headers) self.send(encode(packed_frame))
def transmit(self, frame): """ Convert a frame object to a frame string and transmit to the server. :param Frame frame: the Frame object to transmit """ with self.__listeners_change_condition: listeners = list(self.listeners.values()) for listener in listeners: if not listener: continue try: listener.on_send(frame) except AttributeError: continue lines = utils.convert_frame(frame) packed_frame = pack(lines) if log.isEnabledFor(logging.DEBUG): log.debug("Sending frame: %s", lines) else: log.info("Sending frame: %r, headers=%r", frame.cmd or "heartbeat", utils.clean_headers(frame.headers)) self.send(packed_frame)
def transmit(self, frame): """ Convert a frame object to a frame string and transmit to the server. """ for listener in self.listeners.values(): if not listener: continue if not hasattr(listener, 'on_send'): continue listener.on_send(frame) lines = utils.convert_frame_to_lines(frame) packed_frame = pack(lines) if log.isEnabledFor(logging.DEBUG): log.debug("Sending frame %s", lines) else: log.info("Sending frame cmd=%r headers=%r", frame.cmd, frame.headers) if self.socket is not None: try: self.__socket_semaphore.acquire() try: self.send_over_socket(encode(packed_frame)) finally: self.__socket_semaphore.release() except Exception: _, e, _ = sys.exc_info() log.error("Error sending frame", exc_info=1) raise e else: raise exception.NotConnectedException()
def transmit(self, frame): """ Convert a frame object to a frame string and transmit to the server. :param Frame frame: the Frame object to transmit """ with self.__listeners_change_condition: listeners = sorted(self.listeners.items()) for (_, listener) in listeners: if not listener: continue try: listener.on_send(frame) except AttributeError: continue if frame.cmd == CMD_DISCONNECT and HDR_RECEIPT in frame.headers: self.__disconnect_receipt = frame.headers[HDR_RECEIPT] lines = utils.convert_frame(frame) packed_frame = pack(lines) if log.isEnabledFor(logging.DEBUG): log.debug("Sending frame: %s", lines) else: log.info("Sending frame: %r", frame.cmd or "heartbeat") self.send(packed_frame)
def transmit(self, frame): """ Convert a frame object to a frame string and transmit to the server. """ for listener in self.listeners.values(): if not listener: continue if not hasattr(listener, 'on_send'): continue listener.on_send(frame) lines = utils.convert_frame_to_lines(frame) packed_frame = pack(lines) if log.isEnabledFor(logging.DEBUG): log.debug("Sending frame %s", lines) else: log.info("Sending frame cmd=%r headers=%r", frame.cmd, frame.headers) self.send(encode(packed_frame))
def transmit(self, frame): """ Convert a frame object to a frame string and transmit to the server. :param Frame frame: the Frame object to transmit """ for listener in self.listeners.values(): if not listener: continue try: listener.on_send(frame) except AttributeError: continue lines = utils.convert_frame_to_lines(frame) packed_frame = pack(lines) if log.isEnabledFor(logging.DEBUG): log.debug("Sending frame: %s", lines) else: log.info("Sending frame: %r, headers=%r", frame.cmd or "heartbeat", frame.headers) self.send(encode(packed_frame))