Copilot commented on code in PR #51631:
URL: https://github.com/apache/arrow/pull/51631#discussion_r4132183437


##########
python/pyarrow/io.pxi:
##########
@@ -193,6 +193,20 @@ cdef class NativeFile(_Weakrefable):
                 else:
                     check_status(self.output_stream.get().Close())
 
+    def abort(self):
+        """
+        Close the stream, discarding written data if the stream supports it.
+
+        For example, an S3 output stream aborts its multipart upload, so no
+        object is written. Other streams are simply closed.
+        """
+        if not self.closed:
+            with nogil:
+                if self.is_readable:
+                    check_status(self.input_stream.get().Abort())
+                else:
+                    check_status(self.output_stream.get().Abort())

Review Comment:
   If an S3 abort request fails, `ObjectOutputStream::Abort()` returns before 
setting `closed_` (`cpp/src/arrow/filesystem/s3fs.cc:1759-1770`). 
`check_status` then raises, but the surrounding `with` calls `close()` during 
unwinding (and the C++ destructor also closes), which can complete the 
multipart upload that the caller tried to discard. Make a failed abort 
terminal/non-committing in the C++ stream and cover this failure path before 
exposing it through this pattern.



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