VishakBaddur commented on code in PR #77020:
URL: https://github.com/apache/airflow/pull/77020#discussion_r4659214411


##########
task-sdk/src/airflow/sdk/execution_time/supervisor.py:
##########
@@ -1805,6 +1820,9 @@ def wait(self) -> int:
             self._monitor_subprocess()
         finally:
             self.selector.close()
+            if self._gc_frozen:
+                gc.unfreeze()

Review Comment:
   Follow-up, my suggested gate is wrong on Python 3.12: a fresh 3.12 
interpreter already has a non-zero freeze count, so `gc.get_freeze_count() == 
0` is false from startup and the freeze is skipped.
   
   ```console
   $ docker run --rm --entrypoint python apache/airflow:slim-3.4.0-python3.12 
-I -S -c "import gc; print(gc.get_freeze_count())"
   375
   $ docker run --rm --entrypoint python apache/airflow:slim-3.4.0-python3.13 
-I -S -c "import gc; print(gc.get_freeze_count())"
   0
   ```
   
   Same 375 on uv's CPython 3.12.12 on macOS; 3.10, 3.11 and 3.13 all start at 
0. So on 3.12, a KubernetesExecutor pod, including the image the measurements 
were taken on, never freezes with the current version.
   
   It also shows up in the tests: 
`test_activity_start_prepares_supervisor_before_bare_fork[bare-fork]` fails on 
3.12 when run alone (`assert 375 == 0` in `import_task_runner`), and passes in 
a full run only when a test whose `finally: gc.unfreeze()` clears the startup 
count happens to run first.
   
   Sorry for steering you there. Comparing against 0 can't tell "a host froze 
before us" apart from the interpreter's own startup count. A baseline taken 
when the supervisor is imported isn't obviously safe either, since 
`run_workload` imports it lazily, so whether that happens before or after a 
host's freeze depends on the process.



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