uranusjr commented on code in PR #75446:
URL: https://github.com/apache/airflow/pull/75446#discussion_r4397210955
##########
task-sdk/src/airflow/sdk/execution_time/supervisor.py:
##########
@@ -2155,12 +2180,18 @@ def _handle_start_execution_timeout(
self._arm_execution_timeout()
return None, {}
- def _arm_execution_timeout(self) -> None:
+ def _arm_execution_timeout(self, grace_period: float | None = None) ->
None:
+ """
+ Start the ``execution_timeout`` clock; the task is sent SIGTERM
``grace_period`` after it elapses.
+
+ ``grace_period`` defaults to ``killed_task_cleanup_time``, the
backstop for a Python task, which
+ raises ``AirflowTaskTimeout`` itself when the timeout elapses.
+ """
if self._execution_timeout_seconds is None:
return
- self._execution_timeout_enforce_at = (
- time.monotonic() + self._execution_timeout_seconds +
KILLED_TASK_CLEANUP_TIME
- )
+ if grace_period is None:
+ grace_period = KILLED_TASK_CLEANUP_TIME
+ self._execution_timeout_enforce_at = time.monotonic() +
self._execution_timeout_seconds + grace_period
Review Comment:
Prefer polymorphism over a sentinel argument. Give ActivitySubprocess an
overridable class attribute or property, such as
`_execution_timeout_grace_period`, defaulting to `KILLED_TASK_CLEANUP_TIME`,
and override it to 0 in _PopenActivitySubprocess.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]