Skip to content

Commit

Permalink
Merge pull request #2589 from activeloopai/remove_dataloader_close
Browse files Browse the repository at this point in the history
Remove dataloader close
  • Loading branch information
levongh authored Sep 8, 2023
2 parents 06008ad + ec35c70 commit ce8fad9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion deeplake/enterprise/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,9 @@ def sample_by(

def close(self):
"""Shuts down the workers and releases the resources."""
if self._internal_iterator is not None:
self._internal_iterator = None
if self._dataloader is not None:
self._dataloader.close()
self._dataloader = None

def pytorch(
Expand Down Expand Up @@ -781,8 +782,10 @@ def __iter__(self):

dataset_read(self._orig_dataset)


if self._internal_iterator is not None:
self._internal_iterator = iter(self._internal_iterator)

return self

def __next__(self):
Expand All @@ -792,6 +795,9 @@ def __next__(self):
self._internal_iterator = iter(self._dataloader)
return next(self._internal_iterator)

def __del__(self):
self.close()


def dataloader(dataset, ignore_errors: bool = False) -> DeepLakeDataLoader:
"""Returns a :class:`~deeplake.enterprise.dataloader.DeepLakeDataLoader` object which can be transformed to either pytorch dataloader or numpy.
Expand Down

0 comments on commit ce8fad9

Please sign in to comment.