Cannot close the hdf5 in dataloader?

Hi,

include a __del__ function.

class H5Loader(data.Dataset):

    def __init__(self):
        self.hdf5_files = ['1.h5', '2.h5', '3.h5']
        self.data_lst = []
        for ind in range (len(self.hdf5_list)):
            self.h5_file = h5py.File(self.hdf5_list[ind])
            data_ = self.h5_file.get('data')
            self.data_lst.append(data_)
            #h5_file.close()
            
    def __getitem__(self, index):
        self.data = np.asarray(self.data_lst[index])        
        return torch.from_numpy(self.data).float()

    def __len__(self):
        return len(self.hdf5_list)

    def __del__(self):
        self.h5_file.close()

but see also this problem with hdf5.

Regards,
Foivos