[DataPipe] Fixes an issue where TarArchiveReader closes stream when read into a buffer (#65877)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/65877
Fixes #65808
Test Plan: Imported from OSS
Reviewed By: ejguan
Differential Revision: D31296041
Pulled By: NivekT
fbshipit-source-id: cdcad3a333ae9781d6063678a122a128955b0ff4
diff --git a/torch/utils/data/datapipes/iter/tararchivereader.py b/torch/utils/data/datapipes/iter/tararchivereader.py
index 2abb368..3408b9f 100644
--- a/torch/utils/data/datapipes/iter/tararchivereader.py
+++ b/torch/utils/data/datapipes/iter/tararchivereader.py
@@ -57,8 +57,6 @@
warnings.warn(
"Unable to extract files from corrupted tarfile stream {} due to: {}, abort!".format(pathname, e))
raise e
- finally:
- data_stream.close()
def __len__(self):
if self.length == -1: