(self)
Watches queues for growth and reports errors
Watches queues for growth and reports errors
Watches queues for growth and reports errors
async def _queue_monitor(self):
        """Watches queues for growth and reports errors"""
        self._monitor_ready.set()

        previous_size = None
        while True:
            current_size = self.queue.qsize()

            show_size_warning = current_size >= self.size_warning and current_size != previous_size
            queue_has_shrunk = (
                previous_size is not None
                and current_size < previous_size
                and previous_size >= self.size_warning
            )

            if show_size_warning or queue_has_shrunk:
                if queue_has_shrunk:
                    if not show_size_warning:
                        everything_ok = " Queue is now at an OK size again."
                    else:
                        everything_ok = ""

                    logger.warning(
                        "Queue in %s has shrunk back down to %s commands.%s",
                        self.__class__.__name__,
                        current_size,
                        everything_ok,
                    )
                elif show_size_warning:
                    logger.warning(
                        "Queue in %s now has %s commands.", self.__class__.__name__, current_size
                    )

            previous_size = current_size
            await asyncio.sleep(self.monitor_interval)
async def _queue_monitor ( self ) : self . _monitor_ready . set ( ) previous_size = None while True : current_size = self . queue . qsize ( ) show_size_warning = current_size >= self . size_warning and current_size != previous_size queue_has_shrunk = ( previous_size is not None and current_size < previous_size and previous_size >= self . size_warning ) if show_size_warning or queue_has_shrunk : if queue_has_shrunk : if not show_size_warning : everything_ok = " Queue is now at an OK size again." else : everything_ok = "" logger . warning ( "Queue in %s has shrunk back down to %s commands.%s" , self . __class__ . __name__ , current_size , everything_ok , ) elif show_size_warning : logger . warning ( "Queue in %s now has %s commands." , self . __class__ . __name__ , current_size ) previous_size = current_size await asyncio . sleep ( self . monitor_interval )