code: def fetch_task_to_run(self):
          
          # All the tasks are done so raise an exception
          # that will be handled by the client code.
          if all(task.is_completed for task in self):
              raise StopIteration("All tasks completed.")
  
          for task in self:
              if task.can_run:
                  return task
  
          # No task found, this usually happens when we have dependencies.
          # Beware of possible deadlocks here!
          logger.warning("Possible deadlock in fetch_task_to_run!")
          return None
docs: Returns the first task that is ready to run or
          None if no task can be submitted at present"
  
          Raises:
              `StopIteration` if all tasks are done.