send.py should write everything to stdout (without buffering)

This commit is contained in:
Roman Zeyde
2014-07-21 15:12:31 +03:00
parent 99aad60700
commit f8d5ed6194
4 changed files with 35 additions and 31 deletions

View File

@@ -73,14 +73,17 @@ def dumps(sym, n=1):
return data * n
def iterate(data, size, func=None):
def iterate(data, size, func=None, truncate=True):
offset = 0
data = iter(data)
while True:
done = False
while not done:
buf = list(itertools.islice(data, size))
if len(buf) < size:
return
if truncate or not buf:
return
done = True
buf = np.array(buf)
result = func(buf) if func else buf