So I figured out that the part where I use with open inside the __init__ method seems to be the issue, when I don’t do that it seems to work. Basically as long as I only open the HDF5 file within the __getitem__ and __len__ methods it works.