`iter_bliss_scan_data` does not close the file properly except when using a simple loop on the iterator
Originally posted in ewoksxrpd!177 (comment 343417)
The file is apparently not properly closed when using something else than a simple loop on the iterator:
✅ Works
lima_iterator = bliss.iter_bliss_scan_data(
filename,
scan,
lima_names=[detector_name],
subscan=subscan,
)
for limadata in lima_iterator:
image = limadata[detector_name]
with h5py.File(filename, "r") as h5file:
pass
❌ Fails
Using next
for i in range(nbpoints):
limadata = next(lima_iterator)
image = limadata[detector_name]
with h5py.File(filename, "r") as h5file:
pass
Using zip
with another iterator
for i, limadata in zip(range(nbpoints), lima_iterator):
image = limadata[detector_name]
with h5py.File(filename, "r") as h5file:
pass