prevents I/O from dominating computation time when using progress

This commit is contained in:
aduriseti
2016-09-26 21:17:01 -07:00
parent 0b668811f9
commit f1f6ea57da

View File

@@ -66,18 +66,20 @@ class Infinite(object):
pass
def next(self, n=1):
if n > 0:
now = time()
dt = now - self._ts
if dt < self.time_threshold:
self._pending += n
else:
self._xput.append((n + self._pending) / dt)
self._ts = now
self._pending = 0
if n <= 0:
return
now = time()
dt = now - self._ts
if dt < self.time_threshold:
self._pending += n
else:
# avoid performing computationally intensive update task
# more than 1/dt (10 by default) times a second
self._xput.append((self._pending + n) / dt)
self._ts = now
self._pending = 0
self.update()
self.index = self.index + n
self.update()
def iter(self, it):
try: