Skip to content

Commit

Permalink
Fix an error raised when some node data are empty.
Browse files Browse the repository at this point in the history
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
dahlia committed Jan 14, 2012
1 parent 378da2c commit 7574c90
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions linesman/middleware.py
Expand Up @@ -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):
Expand Down

0 comments on commit 7574c90

Please sign in to comment.