Here's how to do it (I could not figure out how to check if a file is closed without exceptions, maybe you will find):
import gc for obj in gc.get_objects():
Another idea:
How to use files, how to use context manager and with keyword?
with h5py.File("some_path.h5") as f: f["data1"] = some_data
When the program stream exits the c-block, the file closes regardless of what happens, including exceptions, etc.
honza_p
source share