未验证 提交 5df8fc28 编写于 作者: L LielinJiang 提交者: GitHub

fix windows hang (#627)

上级 0908e540
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
# limitations under the License. # limitations under the License.
import os import os
import sys
import time import time
import copy import copy
...@@ -35,6 +36,7 @@ class IterLoader: ...@@ -35,6 +36,7 @@ class IterLoader:
self._dataloader = dataloader self._dataloader = dataloader
self.iter_loader = iter(self._dataloader) self.iter_loader = iter(self._dataloader)
self._epoch = 1 self._epoch = 1
self._inner_iter = 0
@property @property
def epoch(self): def epoch(self):
...@@ -42,12 +44,17 @@ class IterLoader: ...@@ -42,12 +44,17 @@ class IterLoader:
def __next__(self): def __next__(self):
try: try:
if sys.platform == "Windows" and self._inner_iter == len(
self._dataloader) - 1:
self._inner_iter = 0
raise StopIteration
data = next(self.iter_loader) data = next(self.iter_loader)
except StopIteration: except StopIteration:
self._epoch += 1 self._epoch += 1
self.iter_loader = iter(self._dataloader) self.iter_loader = iter(self._dataloader)
data = next(self.iter_loader) data = next(self.iter_loader)
self._inner_iter += 1
return data return data
def __len__(self): def __len__(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册