From 95563b5ce3082f61646ae99dd53ab0e282a0d291 Mon Sep 17 00:00:00 2001 From: Levon Ghukasyan Date: Thu, 7 Sep 2023 17:58:18 +0000 Subject: [PATCH] fix functionality --- deeplake/enterprise/dataloader.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/deeplake/enterprise/dataloader.py b/deeplake/enterprise/dataloader.py index 0d87419da1..f86803436a 100644 --- a/deeplake/enterprise/dataloader.py +++ b/deeplake/enterprise/dataloader.py @@ -394,8 +394,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( @@ -709,8 +710,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): @@ -720,6 +723,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.