code: def queuestats(self):
          
  
          start_time = time.time()
          log.debug("Starting queue stats...")
  
          # Fetch all known queues
          queues = [Queue(q) for q in Queue.all_known()]
  
          new_queues = {queue.id for queue in queues}
          old_queues = set(self.queue_etas.keys())
  
          for deleted_queue in old_queues.difference(new_queues):
              self.queue_etas.pop(deleted_queue)
  
          t = time.time()
          stats = {}
  
          for queue in queues:
              cnt = queue.count_jobs_to_dequeue()
              eta = self.queue_etas[queue.id].next(cnt, t=t)
  
              # Number of jobs to dequeue, ETA, Time of stats
              stats[queue.id] = "%d %s %d" % (cnt, eta if eta is not None else "N", int(t))
  
          with connections.redis.pipeline(transaction=True) as pipe:
              if random.randint(0, 100) == 0 or len(stats) == 0:
                  pipe.delete(self.redis_queuestats_key)
              if len(stats) > 0:
                  pipe.hmset(self.redis_queuestats_key, stats)
              pipe.execute()
  
          log.debug("... done queue stats in %0.4fs" % (time.time() - start_time))
docs: Compute ETAs for every known queue & subqueue