Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions airflow-core/newsfragments/70280.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Restored support for ``[core] execute_tasks_new_python_interpreter`` when running tasks with LocalExecutor and CeleryExecutor.
6 changes: 4 additions & 2 deletions task-sdk/src/airflow/sdk/execution_time/supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,10 @@ def exit(n: int) -> NoReturn:


def _should_use_exec() -> bool:
"""Whether forked children should ``exec`` a fresh interpreter on this platform."""
return sys.platform in _FORK_EXEC_PLATFORMS
"""Whether forked children should ``exec`` a fresh interpreter."""
return sys.platform in _FORK_EXEC_PLATFORMS or conf.getboolean(
"core", "execute_tasks_new_python_interpreter", fallback=False
)


def _resolve_child_target(dotted: str) -> Callable[[], None]:
Expand Down
11 changes: 11 additions & 0 deletions task-sdk/tests/task_sdk/execution_time/test_supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@
TI_ID = uuid7()


@pytest.mark.parametrize(
("platform", "config_value", "expected"),
[("darwin", False, True), ("linux", True, True), ("linux", False, False)],
)
def test_should_use_exec_honors_platform_and_config(monkeypatch, platform, config_value, expected):
monkeypatch.setattr(supervisor.sys, "platform", platform)
monkeypatch.setattr(supervisor.conf, "getboolean", lambda *args, **kwargs: config_value)

assert supervisor._should_use_exec() is expected


def lineno():
"""Returns the current line number in our program."""
return inspect.currentframe().f_back.f_lineno
Expand Down