Exception on csv.read_csv() leaves opened handle on Windows
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Describe the bug, including details regarding any error messages, version, and platform.
On Windows via pyarrow reading CSV file with a very, very, very long field (several million characters).
Since we don't know ahead of time length of the column - keep trying to read doubling buffer size.
Issue is that upon exception file seems to be not properly closed leaving an open handle and preventing temporary file(s) from being removed.
Python code:
```
while True:
try:
table = csv.read_csv(csv_file_path, read_options=read_options, parse_options=parse_options,
convert_options=convert_options)
break
except pa.lib.ArrowInvalid:
print(f'Doubling CSV block_size from {read_options.block_size}')
read_options.block_size *= 2
```
This issue is possibly related to https://github.com/apache/arrow/issues/31796 since it seems to be about properly closing file handles on Windows.
### Component(s)
C++, Python
Contributor guide
Assessment
This issue has not been assessed yet.