parameters: (self)
docstring: Run until all tasks have been completed.
  
          :raises RuntimeError: if a deadlock is detected.
docstring_summary: Run until all tasks have been completed.
docstring_tokens: Run until all tasks have been completed .
function: def flush_tasks(self):
          """Run until all tasks have been completed.
  
          :raises RuntimeError: if a deadlock is detected.
          """
          i = 0
          while self._pending_tasks:
              i += 1
              if i > 1000000:
                  # Detect deadlock/circular dependency by measuring how many times tasks have been
                  # executed. On the big tests/test1.yaml we only get to a fraction of this, so
                  # this shouldn't be a problem.
                  raise RuntimeError(
                      "Circular dependency detected! "
                      "Please run with -v option to see what functions failed to "
                      "complete."
                  )
  
              task: _Task = heapq.heappop(self._pending_tasks)
              _LOGGER.debug(
                  "Running %s in %s (num %s)",
                  task.original_function.__qualname__,
                  task.original_function.__module__,
                  task.id_number,
              )
  
              try:
                  next(task.iterator)
                  # Decrease priority over time, so that if this task is blocked
                  # due to a dependency others will clear the dependency
                  # This could be improved with a less naive approach
                  new_task = task.with_priority(task.priority - 1)
                  heapq.heappush(self._pending_tasks, new_task)
              except StopIteration:
                  _LOGGER.debug(" -> finished")
function_tokens: def flush_tasks ( self ) : i = 0 while self . _pending_tasks : i += 1 if i > 1000000 : # Detect deadlock/circular dependency by measuring how many times tasks have been # executed. On the big tests/test1.yaml we only get to a fraction of this, so # this shouldn't be a problem. raise RuntimeError ( "Circular dependency detected! " "Please run with -v option to see what functions failed to " "complete." ) task : _Task = heapq . heappop ( self . _pending_tasks ) _LOGGER . debug ( "Running %s in %s (num %s)" , task . original_function . __qualname__ , task . original_function . __module__ , task . id_number , ) try : next ( task . iterator ) # Decrease priority over time, so that if this task is blocked # due to a dependency others will clear the dependency # This could be improved with a less naive approach new_task = task . with_priority ( task . priority - 1 ) heapq . heappush ( self . _pending_tasks , new_task ) except StopIteration : _LOGGER . debug ( " -> finished" )