Hi,
I’ve noticed that sometimes the closing of the opened resource helps. Using @victorhcm’s example I’m using the following kind of setup:
class MyDataSet(Dataset):
  def __init__(self, filename):
       self.zip_handle = None
       self.fname = filename

   def __getitem__(self, x):
       with zipfile.ZipFile(self.fname, 'r') as zip_handle:
           # do stuff while file is open
       # file is now closed

To add, my go-to files are either CSV’s or CSV-derived local SQLite databases. Especially the latter are very sensitive to leaving the connections open, i.e.
    ...
    def __getitem__(self, x):
        with self.db:
            #do stuff and close after
    ....

Petteri