提交 ef5c4197 编写于 作者: D dengkaipeng

not reset when max_iters unset

上级 91823e97
...@@ -119,7 +119,7 @@ class ParallelMap(object): ...@@ -119,7 +119,7 @@ class ParallelMap(object):
self._producer = threading.Thread( self._producer = threading.Thread(
target=self._produce, target=self._produce,
args=('producer-' + id, self._source, self._inq)) args=('producer-' + id, self._source, self._inq))
self._producer.daemon = False self._producer.daemon = True
self._consumers = [] self._consumers = []
self._consumer_endsig = {} self._consumer_endsig = {}
...@@ -130,7 +130,7 @@ class ParallelMap(object): ...@@ -130,7 +130,7 @@ class ParallelMap(object):
target=self._consume, target=self._consume,
args=(consumer_id, self._inq, self._outq, self._worker)) args=(consumer_id, self._inq, self._outq, self._worker))
self._consumers.append(p) self._consumers.append(p)
p.daemon = use_process p.daemon = True
setattr(p, 'id', consumer_id) setattr(p, 'id', consumer_id)
if use_process: if use_process:
worker_set.add(p) worker_set.add(p)
......
...@@ -304,9 +304,11 @@ class Reader(object): ...@@ -304,9 +304,11 @@ class Reader(object):
if self._epoch < 0: if self._epoch < 0:
self.reset() self.reset()
if self.drained(): if self.drained():
self.stop()
raise StopIteration raise StopIteration
batch = self._load_batch() batch = self._load_batch()
if self._drop_last and len(batch) < self._batch_size: if self._drop_last and len(batch) < self._batch_size:
self.stop()
raise StopIteration raise StopIteration
if self._worker_num > -1: if self._worker_num > -1:
return batch return batch
...@@ -418,8 +420,8 @@ def create_reader(cfg, max_iter=0, global_cfg=None, devices_num=1): ...@@ -418,8 +420,8 @@ def create_reader(cfg, max_iter=0, global_cfg=None, devices_num=1):
n += 1 n += 1
if max_iter > 0 and n == max_iter: if max_iter > 0 and n == max_iter:
return return
reader.reset()
if max_iter <= 0: if max_iter <= 0:
return return
reader.reset()
return _reader return _reader
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册