You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Over in #3827 the point was raised that it would be useful to have an option, when closing a FITS file, to make sure all handles to that file, including handles used by mmap'd data arrays are closed. This could be an optional argument to HDUList.close() and / or an argument to fits.open (and hence HDUList.fromfile) that ensures this cleanup is performed when the file is closed.
This might also be a decent opportunity to revisit what the default behavior should be. I'm on the fence.
It's worth adding that if my plans for a FITSData container object ever come to fruition, this could be handled more transparently at a lower level. The FITSData could handle opening and closing mmaps on an as-needed basis, so that merely accessing hdu.data (which would return a FITSData or some higher-level wrapper around that) does not cause any side-effects like opening file handles.
The text was updated successfully, but these errors were encountered:
As discussed in #4097, it turns out that HDUList.close() already closes any mmaps in use, and they'll only hang around if there are any external references to an array with a mmap buffer. However, since we don't know how those external references will be used, we need to leave the mmap open (otherwise Numpy segfaults, though even if that weren't the case it would result in surprising behavior to the user when they suddenly can't read their array anymore). So as written this isn't really a good idea.
The possibility for a FITSData container to improve this situation still stands, and is something I will keep in mind for the future.
Over in #3827 the point was raised that it would be useful to have an option, when closing a FITS file, to make sure all handles to that file, including handles used by mmap'd data arrays are closed. This could be an optional argument to
HDUList.close()
and / or an argument tofits.open
(and henceHDUList.fromfile
) that ensures this cleanup is performed when the file is closed.This might also be a decent opportunity to revisit what the default behavior should be. I'm on the fence.
It's worth adding that if my plans for a
FITSData
container object ever come to fruition, this could be handled more transparently at a lower level. TheFITSData
could handle opening and closing mmaps on an as-needed basis, so that merely accessinghdu.data
(which would return aFITSData
or some higher-level wrapper around that) does not cause any side-effects like opening file handles.The text was updated successfully, but these errors were encountered: