This is an automated email from the ASF dual-hosted git repository.
vincbeck pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 7fee3e90023 Don't import/load executor if it's not necessary (#55742)
7fee3e90023 is described below
commit 7fee3e9002374edd2ae61938469630d3fea0fe16
Author: Niko Oliveira <[email protected]>
AuthorDate: Wed Sep 17 07:01:49 2025 -0700
Don't import/load executor if it's not necessary (#55742)
If we are skipping log serving there is no need to import/load the
executor to check if it supports log serving.
---
airflow-core/src/airflow/cli/commands/scheduler_command.py | 6 +++---
airflow-core/tests/unit/cli/commands/test_scheduler_command.py | 3 +--
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/airflow-core/src/airflow/cli/commands/scheduler_command.py
b/airflow-core/src/airflow/cli/commands/scheduler_command.py
index 15093fd24d0..f0437710f95 100644
--- a/airflow-core/src/airflow/cli/commands/scheduler_command.py
+++ b/airflow-core/src/airflow/cli/commands/scheduler_command.py
@@ -62,9 +62,9 @@ def _serve_logs(skip_serve_logs: bool = False):
from airflow.utils.serve_logs import serve_logs
sub_proc = None
- executor_class, _ = ExecutorLoader.import_default_executor_cls()
- if executor_class.serve_logs:
- if skip_serve_logs is False:
+ if skip_serve_logs is False:
+ executor_class, _ = ExecutorLoader.import_default_executor_cls()
+ if executor_class.serve_logs:
sub_proc = Process(target=serve_logs)
sub_proc.start()
try:
diff --git a/airflow-core/tests/unit/cli/commands/test_scheduler_command.py
b/airflow-core/tests/unit/cli/commands/test_scheduler_command.py
index 8c6958159d0..63630cb7fd6 100644
--- a/airflow-core/tests/unit/cli/commands/test_scheduler_command.py
+++ b/airflow-core/tests/unit/cli/commands/test_scheduler_command.py
@@ -70,8 +70,7 @@ class TestSchedulerCommand:
with conf_vars({("core", "executor"): executor}):
reload(executor_loader)
scheduler_command.scheduler(args)
- with pytest.raises(AssertionError):
- mock_process.assert_has_calls([mock.call(target=serve_logs)])
+ assert mock_process.call_count == 0
@mock.patch("airflow.utils.db.check_and_run_migrations")
@mock.patch("airflow.utils.db.synchronize_log_template")