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

fix windows hang (#627)

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