diff --git a/src/litdata/streaming/reader.py b/src/litdata/streaming/reader.py index 078c9fa2..cfbe8d43 100644 --- a/src/litdata/streaming/reader.py +++ b/src/litdata/streaming/reader.py @@ -336,7 +336,7 @@ def __getstate__(self) -> Dict[str, Any]: return state def __del__(self) -> None: - if self._prepare_thread and not self._prepare_thread._has_exited: + if hasattr(self, "_prepare_thread") and self._prepare_thread and not self._prepare_thread._has_exited: self._prepare_thread.force_stop() self._prepare_thread = None