Usiel commented on code in PR #32709:
URL: https://github.com/apache/airflow/pull/32709#discussion_r1273035241


##########
airflow/models/pool.py:
##########
@@ -290,6 +312,25 @@ def scheduled_slots(self, session: Session = NEW_SESSION) 
-> int:
             or 0
         )
 
+    @provide_session
+    def deferred_slots(self, session: Session = NEW_SESSION) -> int:
+        """
+        Get the number of slots deferred at the moment.
+
+        :param session: SQLAlchemy ORM Session
+        :return: the number of deferred slots
+        """
+        from airflow.models.taskinstance import TaskInstance  # Avoid circular 
import
+
+        return int(
+            session.scalar(
+                select(func.sum(TaskInstance.pool_slots))
+                .filter(TaskInstance.pool == self.pool)
+                .filter(TaskInstance.state == TaskInstanceState.DEFERRED)

Review Comment:
   Committed with a fix for formatting 👍 



##########
airflow/models/pool.py:
##########
@@ -290,6 +312,25 @@ def scheduled_slots(self, session: Session = NEW_SESSION) 
-> int:
             or 0
         )
 
+    @provide_session
+    def deferred_slots(self, session: Session = NEW_SESSION) -> int:
+        """
+        Get the number of slots deferred at the moment.
+
+        :param session: SQLAlchemy ORM Session
+        :return: the number of deferred slots
+        """
+        from airflow.models.taskinstance import TaskInstance  # Avoid circular 
import
+
+        return int(
+            session.scalar(
+                select(func.sum(TaskInstance.pool_slots))
+                .filter(TaskInstance.pool == self.pool)
+                .filter(TaskInstance.state == TaskInstanceState.DEFERRED)

Review Comment:
   Committed with a fix for formatting 👍 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to