Skip to content

Commit

Permalink
Fix #817 Check that __open_links exists before trying to clsoe links
Browse files Browse the repository at this point in the history
  • Loading branch information
oruebel committed Jan 19, 2023
1 parent 615538a commit 184b4a6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/hdmf/backends/hdf5/h5tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,10 +746,15 @@ def close_linked_files(self):
not, which prevents the linked-to file from being deleted or truncated. Use this method to close all opened,
linked-to files.
"""
for obj in self.__open_links:
if obj:
obj.file.close()
self.__open_links = []
# Make sure
try:
for obj in self.__open_links:
if obj:
obj.file.close()
except AttributeError: # In case that self.__open_links does not exist on delete
pass
finally:
self.__open_links = []

@docval({'name': 'builder', 'type': GroupBuilder, 'doc': 'the GroupBuilder object representing the HDF5 file'},
{'name': 'link_data', 'type': bool,
Expand Down

0 comments on commit 184b4a6

Please sign in to comment.