def _consume(cnx: BrokerConnection, timesup: int) -> None: try: cnx.drain_events(timeout=timesup) except kombu_exceptions.TimeoutError: self._logger.debug("Time out reading from queue %s", self._queue_name) cnx.heartbeat_check() except(kombu_exceptions.ChannelLimitExceeded, kombu_exceptions.ConnectionLimitExceeded, kombu_exceptions.OperationalError, kombu_exceptions.NotBoundError, kombu_exceptions.MessageStateError, kombu_exceptions.LimitExceeded) as err: raise ChannelFailureException("Error connecting to RabbitMQ, see inner exception for details", err) except (OSError, IOError, ConnectionError) as socket_err: self._reset_connection() raise ChannelFailureException("Error connecting to RabbitMQ, see inner exception for details", socket_err)
def _send_heartbeat(cnx: BrokerConnection, period: int, logger: logging.Logger) -> None: while not cancellation_event.is_set(): cnx.heartbeat_check() cancellation_event.wait(timeout= period) logger.debug("Signalled to exit long-running handler heartbeat")