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 15e412d552adc..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! @@ -360,11 +361,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,