From 496d0f26689acd59b47dfd20fd89a1ff9aa15328 Mon Sep 17 00:00:00 2001 From: henry3260 Date: Wed, 4 Feb 2026 02:49:28 +0800 Subject: [PATCH 1/2] fix(test): refactor test_reopen_log_fd to use context manager for log fd handling --- task-sdk/tests/task_sdk/execution_time/test_supervisor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/task-sdk/tests/task_sdk/execution_time/test_supervisor.py b/task-sdk/tests/task_sdk/execution_time/test_supervisor.py index 15e412d552adc..282ed4ee14dc7 100644 --- a/task-sdk/tests/task_sdk/execution_time/test_supervisor.py +++ b/task-sdk/tests/task_sdk/execution_time/test_supervisor.py @@ -360,11 +360,12 @@ def subprocess_main(): logs = comms.send(ResendLoggingFD()) assert isinstance(logs, SentFDs) - fd = os.fdopen(logs.fds[0], "w") logging.root.info("Log on old socket") - json.dump({"level": "info", "event": "Log on new socket"}, fp=fd) + with os.fdopen(logs.fds[0], "w") as fd: + json.dump({"level": "info", "event": "Log on new socket"}, fp=fd) + fd.write("\n") - line = lineno() - 3 # Line the error should be on + line = lineno() - 5 # Line the error should be on proc = ActivitySubprocess.start( dag_rel_path=os.devnull, From ed520b2ddb938d958db43c36b483b2d1004608fd Mon Sep 17 00:00:00 2001 From: Henry Chen Date: Wed, 4 Feb 2026 04:21:03 +0800 Subject: [PATCH 2/2] Update test_supervisor.py Co-authored-by: Bugra Ozturk --- task-sdk/pyproject.toml | 3 +++ task-sdk/tests/task_sdk/execution_time/test_supervisor.py | 1 + 2 files changed, 4 insertions(+) diff --git a/task-sdk/pyproject.toml b/task-sdk/pyproject.toml index 350f901ee17bc..4e4e86b6348c7 100644 --- a/task-sdk/pyproject.toml +++ b/task-sdk/pyproject.toml @@ -261,6 +261,9 @@ log_level = "INFO" filterwarnings = [ "error::pytest.PytestCollectionWarning", ] +markers = [ + "flaky: mark test as flaky and rerun on failure", +] python_files = [ "test_*.py", ] diff --git a/task-sdk/tests/task_sdk/execution_time/test_supervisor.py b/task-sdk/tests/task_sdk/execution_time/test_supervisor.py index 282ed4ee14dc7..6ce05fefa1188 100644 --- a/task-sdk/tests/task_sdk/execution_time/test_supervisor.py +++ b/task-sdk/tests/task_sdk/execution_time/test_supervisor.py @@ -350,6 +350,7 @@ def subprocess_main(): ] ) + @pytest.mark.flaky(reruns=3) def test_reopen_log_fd(self, captured_logs, client_with_ti_start): def subprocess_main(): # This is run in the subprocess!