parameters: (self, number_of_tasks: int | None = None)
docstring: Execute the tasks in the queue.
docstring_summary: Execute the tasks in the queue.
docstring_tokens: Execute the tasks in the queue .
function: async def execute(self, number_of_tasks: int | None = None) -> None:
          """Execute the tasks in the queue."""
          if self.running:
              _LOGGER.debug("Execution is allreay running")
              raise HacsExecutionStillInProgress
          if len(self.queue) == 0:
              _LOGGER.debug("The queue is empty")
              return
  
          self.running = True
  
          _LOGGER.debug("Checking out tasks to execute")
          local_queue = []
  
          if number_of_tasks:
              for task in self.queue[:number_of_tasks]:
                  local_queue.append(task)
          else:
              for task in self.queue:
                  local_queue.append(task)
  
          for task in local_queue:
              self.queue.remove(task)
  
          _LOGGER.debug("Starting queue execution for %s tasks", len(local_queue))
          start = time.time()
          await asyncio.gather(*local_queue)
          end = time.time() - start
  
          _LOGGER.debug(
              "Queue execution finished for %s tasks finished in %.2f seconds",
              len(local_queue),
              end,
          )
          if self.has_pending_tasks:
              _LOGGER.debug("%s tasks remaining in the queue", len(self.queue))
          self.running = False
function_tokens: async def execute ( self , number_of_tasks : int | None = None ) -> None : if self . running : _LOGGER . debug ( "Execution is allreay running" ) raise HacsExecutionStillInProgress if len ( self . queue ) == 0 : _LOGGER . debug ( "The queue is empty" ) return self . running = True _LOGGER . debug ( "Checking out tasks to execute" ) local_queue = [ ] if number_of_tasks : for task in self . queue [ : number_of_tasks ] : local_queue . append ( task ) else : for task in self . queue : local_queue . append ( task ) for task in local_queue : self . queue . remove ( task ) _LOGGER . debug ( "Starting queue execution for %s tasks" , len ( local_queue ) ) start = time . time ( ) await asyncio . gather ( * local_queue ) end = time . time ( ) - start _LOGGER . debug ( "Queue execution finished for %s tasks finished in %.2f seconds" , len ( local_queue ) , end , ) if self . has_pending_tasks : _LOGGER . debug ( "%s tasks remaining in the queue" , len ( self . queue ) ) self . running = False