Skip to content

BUG: close file handles in mmap #35748

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

Merged
merged 20 commits into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8eb547e
CI: avoid file leaks in sas_xport tests
jbrockmendel Aug 12, 2020
bd953bf
CLN: reuse context inside decorator
jbrockmendel Aug 12, 2020
c114449
TST: check for leaked socket connections
jbrockmendel Aug 12, 2020
e2e5043
Merge branch 'master' of https://github.com/pandas-dev/pandas into ci…
jbrockmendel Aug 12, 2020
c2a362c
open file later
jbrockmendel Aug 12, 2020
37902db
Merge branch 'master' of https://github.com/pandas-dev/pandas into ci…
jbrockmendel Aug 13, 2020
e75a15b
Fix incorrect file closing in read_sas
jbrockmendel Aug 13, 2020
f337be4
TST: make check_file_leaks an auto-use fixture for all tests
jbrockmendel Aug 12, 2020
6119a92
Merge branch 'master' of https://github.com/pandas-dev/pandas into ci…
jbrockmendel Aug 13, 2020
811b9d0
Merge branch 'master' of https://github.com/pandas-dev/pandas into ci…
jbrockmendel Aug 14, 2020
430567b
BUG: unclosed file handle in mmap
jbrockmendel Aug 14, 2020
1c3bf73
TST: close connections opened by sqlalchemy
jbrockmendel Aug 14, 2020
d499920
CLN: remove unused variable (#35726)
jbrockmendel Aug 14, 2020
239b0b3
agg with list of non-aggregating functions (#35723)
rhshadrach Aug 14, 2020
e0c8fe0
BLD: bump xlrd min version to 1.2.0 (#35728)
jbrockmendel Aug 14, 2020
eab5d63
Fix broken link in cookbook.rst (#35729)
estasney Aug 14, 2020
b610608
Revert parts of #35711
jbrockmendel Aug 15, 2020
4d223dc
Merge branch 'master' of https://github.com/pandas-dev/pandas into ci…
jbrockmendel Aug 15, 2020
3be2f21
mypy fixup
jbrockmendel Aug 15, 2020
9958599
Merge branch 'master' of https://github.com/pandas-dev/pandas into ci…
jbrockmendel Aug 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pandas/io/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
Optional,
Tuple,
Type,
Union,
)
from urllib.parse import (
urljoin,
Expand Down Expand Up @@ -452,7 +453,7 @@ def get_handle(
except ImportError:
need_text_wrapping = (BufferedIOBase, RawIOBase)

handles: List[IO] = list()
handles: List[Union[IO, _MMapWrapper]] = list()
f = path_or_buf

# Convert pathlib.Path/py.path.local or string
Expand Down Expand Up @@ -535,6 +536,8 @@ def get_handle(
try:
wrapped = _MMapWrapper(f)
f.close()
handles.remove(f)
handles.append(wrapped)
f = wrapped
except Exception:
# we catch any errors that may have occurred
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/io/parser/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,7 @@ def test_raise_on_no_columns(all_parsers, nrows):
parser.read_csv(StringIO(data))


@td.check_file_leaks
def test_memory_map(all_parsers, csv_dir_path):
mmap_file = os.path.join(csv_dir_path, "test_mmap.csv")
parser = all_parsers
Expand Down