Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-4823: [C++][Python] Do not close raw file handle in ReadaheadSpooler, check that file handles passed to read_csv are not closed #4610

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions cpp/src/arrow/io/readahead-test.cc
Expand Up @@ -193,8 +193,12 @@ TEST(ReadaheadSpooler, Close) {

AssertEventualPosition(*data_reader, 2 * 2);
ASSERT_OK(spooler.Close());

// Idempotency
ASSERT_OK(spooler.Close());

// ARROW-4823: does not close raw
ASSERT_FALSE(data_reader->closed());
}

TEST(ReadaheadSpooler, Paddings) {
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/io/readahead.cc
Expand Up @@ -67,7 +67,7 @@ class ReadaheadSpooler::Impl {
io_worker_.join();
lock.lock();
}
return raw_->Close();
return Status::OK();
}

Status Read(ReadaheadBuffer* out) {
Expand Down
7 changes: 7 additions & 0 deletions python/pyarrow/tests/test_csv.py
Expand Up @@ -495,3 +495,10 @@ class TestBZ2CSVRead(BaseTestCompressedCSVRead, unittest.TestCase):
def write_file(self, path, contents):
with bz2.BZ2File(path, 'w') as f:
f.write(contents)


def test_read_csv_does_not_close_passed_file_handles():
# ARROW-4823
buf = io.BytesIO(b"a,b,c\n1,2,3\n4,5,6")
read_csv(buf)
assert not buf.closed