feng-tao commented on a change in pull request #4949: [AIRFLOW-1557] Backfill
should respect pool limit
URL: https://github.com/apache/airflow/pull/4949#discussion_r268382201
##########
File path: airflow/jobs.py
##########
@@ -2300,9 +2297,35 @@ def _per_task_process(task, key, ti, session=None):
self.log.debug('Adding %s to not_ready', ti)
ti_status.not_ready.add(key)
- for task in self.dag.topological_sort():
- for key, ti in list(ti_status.to_run.items()):
- _per_task_process(task, key, ti)
+ non_pool_slots = conf.getint('core',
'non_pooled_backfill_task_slot_count')
+
+ try:
+ for task in self.dag.topological_sort():
+ for key, ti in list(ti_status.to_run.items()):
+ if task.task_id != ti.task_id:
+ continue
+ if task.pool:
+ pool = session.query(models.Pool) \
+ .filter(models.Pool.pool == task.pool) \
+ .first()
+ if not pool:
+ raise PoolNotFound('Unknown pool:
{}'.format(task.pool))
+
+ open_slots = pool.open_slots(session=session)
+ if open_slots <= 0:
+ raise NoAvailablePoolSlot(
Review comment:
thanks. lgtm
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services