1yangsh opened a new pull request, #77448:
URL: https://github.com/apache/airflow/pull/77448

   `PythonVirtualenvOperator` and `ExternalPythonOperator` (and 
`@task.virtualenv` / `@task.external_python`) run the callable through 
`_execute_in_subprocess`. That function wraps the child in `with 
subprocess.Popen(...) as proc:` and blocks on `readline()` / `wait()`.
   
   While the task is blocked there, `execution_timeout` is raised inside the 
task process by a SIGALRM handler. But `Popen.__exit__` only closes the pipes 
and then calls `wait()` again. It never kills the child, so the 
`AirflowTaskTimeout`, or a termination raised the same way, is held until the 
child exits on its own. If the child hangs, for example on an open network 
connection, the task keeps running past its timeout.
   
   Since #73806 the supervisor eventually kills such a task: SIGTERM, then 
SIGKILL after `killed_task_cleanup_time`. That kill path cannot run `on_kill`, 
the retry policy or failure callbacks, though. This change kills the child as 
soon as the exception is raised, so the timeout is handled in-process as 
intended.
   
   The new test arms a 0.5s SIGALRM against a child that sleeps for 20s. It 
asserts that the child was killed (`returncode == -SIGKILL`) and that the call 
returns well before the child would have finished. On `main` the call is held 
for the full 20s and the child exits normally with return code 0, so the test 
fails.
   
   This picks up #71345, which was closed as stale. It addresses the review 
feedback there: the test fails without the kill, and it starts the child with 
`sys.executable`.
   
   related: #57712, #71345
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   ---
   


-- 
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]

Reply via email to