summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMac Mollison <mollison@cs.unc.edu>2010-03-27 16:50:14 -0400
committerMac Mollison <mollison@cs.unc.edu>2010-03-27 16:50:14 -0400
commitcf8cbbaf8f96bcda3c759583cc5d8c892f7067f0 (patch)
tree5b2be10b911676a17c8e7b413b58607dd56977eb
parent7b18c0df5d1948a5910fc81bdfe874c2da143e76 (diff)
Bugfix: small traces yield no events
A bug caused traces with < 100 records (the number of records buffered and sorted) to yield no records.
-rw-r--r--unit_trace/trace_reader.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/unit_trace/trace_reader.py b/unit_trace/trace_reader.py
index 5cfbbe3..5927250 100644
--- a/unit_trace/trace_reader.py
+++ b/unit_trace/trace_reader.py
@@ -64,9 +64,16 @@ def trace_reader(files):
64 # This is because records may have been recorded slightly out of order 64 # This is because records may have been recorded slightly out of order
65 # This cannot guarantee records are produced in order, but it makes it 65 # This cannot guarantee records are produced in order, but it makes it
66 # overwhelmingly probably. 66 # overwhelmingly probably.
67 # The 'try' and 'except' catches the case where there are less than 100
68 # records in a file (throwing a StopIteration) which otherwise would
69 # propogate up and cause the trace_reader generator itself to throw a
70 # StopIteration.
67 for x in range(0,len(file_iter_buff)): 71 for x in range(0,len(file_iter_buff)):
68 for y in range(0,100): 72 try:
69 file_iter_buff[x].append(file_iters[x].next()) 73 for y in range(0,100):
74 file_iter_buff[x].append(file_iters[x].next())
75 except StopIteration:
76 pass
70 for x in range(0,len(file_iter_buff)): 77 for x in range(0,len(file_iter_buff)):
71 file_iter_buff[x] = sorted(file_iter_buff[x],key=lambda rec: rec.when) 78 file_iter_buff[x] = sorted(file_iter_buff[x],key=lambda rec: rec.when)
72 79