Browse files

Fix an error raised when some node data are empty.

Sometimes node data could be empty (for example, the application
uses gevent.spawn() heavily, but not sure why). In that case, several
points of linesman raise KeyError.

It fixes node data to have 'totaltime' key before graph data are used.
  • Loading branch information...
1 parent 378da2c commit 7574c9030d149245c16130163a0cac15853eb489 @dahlia dahlia committed Jan 14, 2012
Showing with 5 additions and 0 deletions.
  1. +5 −0 linesman/
@@ -413,6 +413,11 @@ def prepare_graph(source_graph, cutoff_time, break_cycles=False):
# Always use a copy for destructive changes
graph = source_graph.copy()
+ # Some node data could be empty dict
+ for node, data in graph.nodes(data=True):
+ if not data:
+ data['totaltime'] = 0
max_totaltime = max(data['totaltime']
for node, data in graph.nodes(data=True))
for node, data in graph.nodes(data=True):

0 comments on commit 7574c90

Please sign in to comment.