4444from airflow .models .dag import DAG
4545from airflow .models .dagrun import DagRun
4646from airflow .models .operator import needs_expansion
47- from airflow .models .taskinstance import TaskReturnCode
4847from airflow .settings import IS_K8S_EXECUTOR_POD
4948from airflow .ti_deps .dep_context import DepContext
5049from airflow .ti_deps .dependencies_deps import SCHEDULER_QUEUED_DEPS
5958 suppress_logs_and_warning ,
6059)
6160from airflow .utils .dates import timezone
62- from airflow .utils .log .file_task_handler import _set_task_deferred_context_var
6361from airflow .utils .log .logging_mixin import StreamLogWriter
6462from airflow .utils .log .secrets_masker import RedactedIO
6563from airflow .utils .net import get_hostname
@@ -184,7 +182,7 @@ def _get_ti(
184182 return ti , dr_created
185183
186184
187- def _run_task_by_selected_method (args , dag : DAG , ti : TaskInstance ) -> None | TaskReturnCode :
185+ def _run_task_by_selected_method (args , dag : DAG , ti : TaskInstance ) -> None :
188186 """
189187 Runs the task based on a mode.
190188
@@ -195,11 +193,11 @@ def _run_task_by_selected_method(args, dag: DAG, ti: TaskInstance) -> None | Tas
195193 - by executor
196194 """
197195 if args .local :
198- return _run_task_by_local_task_job (args , ti )
196+ _run_task_by_local_task_job (args , ti )
199197 elif args .raw :
200- return _run_raw_task (args , ti )
198+ _run_raw_task (args , ti )
201199 else :
202- return _run_task_by_executor (args , dag , ti )
200+ _run_task_by_executor (args , dag , ti )
203201
204202
205203def _run_task_by_executor (args , dag , ti ):
@@ -241,7 +239,7 @@ def _run_task_by_executor(args, dag, ti):
241239 executor .end ()
242240
243241
244- def _run_task_by_local_task_job (args , ti ) -> TaskReturnCode | None :
242+ def _run_task_by_local_task_job (args , ti ):
245243 """Run LocalTaskJob, which monitors the raw task execution process."""
246244 run_job = LocalTaskJob (
247245 task_instance = ti ,
@@ -256,14 +254,11 @@ def _run_task_by_local_task_job(args, ti) -> TaskReturnCode | None:
256254 external_executor_id = _extract_external_executor_id (args ),
257255 )
258256 try :
259- ret = run_job .run ()
257+ run_job .run ()
260258
261259 finally :
262260 if args .shut_down_logging :
263261 logging .shutdown ()
264- with suppress (ValueError ):
265- return TaskReturnCode (ret )
266- return None
267262
268263
269264RAW_TASK_UNSUPPORTED_OPTION = [
@@ -274,9 +269,9 @@ def _run_task_by_local_task_job(args, ti) -> TaskReturnCode | None:
274269]
275270
276271
277- def _run_raw_task (args , ti : TaskInstance ) -> None | TaskReturnCode :
272+ def _run_raw_task (args , ti : TaskInstance ) -> None :
278273 """Runs the main task handling code."""
279- return ti ._run_raw_task (
274+ ti ._run_raw_task (
280275 mark_success = args .mark_success ,
281276 job_id = args .job_id ,
282277 pool = args .pool ,
@@ -412,21 +407,18 @@ def task_run(args, dag=None):
412407 # this should be last thing before running, to reduce likelihood of an open session
413408 # which can cause trouble if running process in a fork.
414409 settings .reconfigure_orm (disable_connection_pool = True )
415- task_return_code = None
410+
416411 try :
417412 if args .interactive :
418- task_return_code = _run_task_by_selected_method (args , dag , ti )
413+ _run_task_by_selected_method (args , dag , ti )
419414 else :
420415 with _move_task_handlers_to_root (ti ), _redirect_stdout_to_ti_log (ti ):
421- task_return_code = _run_task_by_selected_method (args , dag , ti )
422- if task_return_code == TaskReturnCode .DEFERRED :
423- _set_task_deferred_context_var ()
416+ _run_task_by_selected_method (args , dag , ti )
424417 finally :
425418 try :
426419 get_listener_manager ().hook .before_stopping (component = TaskCommandMarker ())
427420 except Exception :
428421 pass
429- return task_return_code
430422
431423
432424@cli_utils .action_cli (check_db = False )
0 commit comments