nuclearpinguin commented on a change in pull request #6725: [AIRFLOW-6157] 
Support for multiple executors

 File path: airflow/executors/
 @@ -0,0 +1,117 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Multiple  executor."""
+from itertools import chain
+from typing import Any, Dict, Iterable, Optional, Set
+from airflow.executors.base_executor import BaseExecutor, 
BaseExecutorProtocol, CommandType
+from airflow.models import TaskInstance
+from airflow.models.taskinstance import SimpleTaskInstance, TaskInstanceKeyType
+class MultipleExecutors(BaseExecutorProtocol):
+    """
+    This executor can run multiple executors under the hood.
+    """
+    def __init__(self, main_executor: BaseExecutor, additional_executors_dict: 
Dict[str, BaseExecutor]):
+        super().__init__()
+        self.main_executor = main_executor
+        self.additional_executors_dict = additional_executors_dict
+        self.executor_set: Set[BaseExecutor] = 
+        self.executor_set.add(main_executor)
+"Multiple executor")
+"Main executor %s", str(main_executor))
+"Additional executor dict %s", 
+"Executor set %s", str(self.executor_set))
+    def _get_executor_for_queue(self, queue: Optional[str]) -> BaseExecutor:
+        executor = None
+        if queue:
+            executor = self.additional_executors_dict.get(queue)
+        return self.main_executor if not executor else executor
+    def start(self):
+        for executor in self.executor_set:
+            executor.start()
+    def has_task(self, task_instance: TaskInstance) -> bool:
+        executor = self._get_executor_for_queue(task_instance.queue)
+        return executor.has_task(task_instance=task_instance)
+    def sync(self) -> None:
+        for executor in self.executor_set:
+            executor.sync()
 Review comment:
   I just wonder if we should use try / except in such loops? Because now when 
first executor fails everything fails. But using exception handling we can 
"execute as much as possible" and then throw an exception. WDYT?

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:

With regards,
Apache Git Services

Reply via email to