anukratb commented on code in PR #75297:
URL: https://github.com/apache/airflow/pull/75297#discussion_r4337243956


##########
task-sdk/tests/task_sdk/execution_time/test_supervisor.py:
##########
@@ -2231,6 +2231,95 @@ def _handler(sig, frame):
         expected_logs.extend(({"event": "Process exited", "logger": 
"supervisor"},))
         assert logs == expected_logs
 
+    def test_wait_terminates_subprocess_when_monitor_raises(self, 
watched_subprocess, mock_process, mocker):
+        monitor_error = OSError(28, "No space left on device")
+        mocker.patch.object(
+            ActivitySubprocess, "_monitor_subprocess", autospec=True, 
side_effect=monitor_error
+        )
+        cleanup_sockets = mocker.patch.object(ActivitySubprocess, 
"cleanup_sockets_after_kill", autospec=True)
+        signal_subprocess = mocker.patch.object(ActivitySubprocess, 
"_signal_subprocess", autospec=True)
+        upload_logs = mocker.patch.object(ActivitySubprocess, "_upload_logs", 
autospec=True)
+        mock_process.wait.return_value = -signal.SIGTERM
+
+        with pytest.raises(OSError, match="No space left on device") as raised:
+            watched_subprocess.wait()
+
+        assert raised.value is monitor_error
+        cleanup_sockets.assert_called_once_with(watched_subprocess)
+        signal_subprocess.assert_called_once_with(watched_subprocess, 
signal.SIGTERM)
+        
mock_process.wait.assert_called_once_with(timeout=supervisor.KILLED_TASK_CLEANUP_TIME)
+        watched_subprocess.selector.close.assert_called_once_with()
+        upload_logs.assert_not_called()

Review Comment:
   @Andrushika agreed again - removed. Left the upload behaviour alone tho to 
keep this PR focussed



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