Skip to content

always close memmaps with the asdf file#1241

Merged
WilliamJamieson merged 1 commit intoasdf-format:masterfrom
braingram:bug/close_memmap_with_context
Nov 23, 2022
Merged

always close memmaps with the asdf file#1241
WilliamJamieson merged 1 commit intoasdf-format:masterfrom
braingram:bug/close_memmap_with_context

Conversation

@braingram
Copy link
Contributor

even when reading an already opened file

fixes issue #1239

update changelog

add regression test docstring

even when reading an already opened file

fixes issue asdf-format#1239

update changelog

add regression test docstring

fix changelog
@braingram braingram force-pushed the bug/close_memmap_with_context branch from cb8bc67 to ac54b61 Compare November 23, 2022 19:15
Comment on lines -783 to -786
if self._close:
if hasattr(self, "_mmap") and not self._mmap.closed:
self._mmap.flush()
self._mmap.close()
Copy link
Contributor

@WilliamJamieson WilliamJamieson Nov 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any additional implications of this change? Besides fixing the error introduced in astropy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None that I've been able to uncover. It does not appear that any other tests aside from the one added in this PR and the ones in astropy (that load a table from asdf) suffer from this issue. With 2.13 memmaps were handled by numpy.memmap which has no api for closing the memmap (as per the docstring here: https://github.com/numpy/numpy/blob/v1.23.0/numpy/core/memmap.py#L40-L43) so it's difficult if not impossible to say we've mimicked the old behavior.
Is there something specific that you had in mind?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it seems like a reasonable change then.

@braingram braingram marked this pull request as ready for review November 23, 2022 20:06
@braingram braingram requested a review from a team as a code owner November 23, 2022 20:06
@braingram
Copy link
Contributor Author

braingram commented Nov 23, 2022

The added regression test fails with asdf 2.14 (and the current master branch) with both pytest-openfiles 0.4.0 and 0.5.0 (as it checks for the number of open files directly instead of relying on the plugin). The test passes with this PR.

I'm inclined to ignore the minor coverage change (-0.01%) but am happy to attempt to update the PR with more coverage if that's preferred.

@WilliamJamieson WilliamJamieson merged commit fdb335b into asdf-format:master Nov 23, 2022
@WilliamJamieson
Copy link
Contributor

I'm inclined to ignore the minor coverage change (-0.01%) but am happy to attempt to update the PR with more coverage if that's preferred.

Coverage seems to fluctuate for strange reasons at times. I didn't see any lines drop coverage so its no big deal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants