Skip to content

Commit

Permalink
Merge pull request #2322 from TimWhalen/master
Browse files Browse the repository at this point in the history
convert prefetched values generator to reusable iterator
  • Loading branch information
deniszh committed Aug 20, 2018
2 parents 5d3a3c9 + e150af4 commit 5a904fd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions webapp/graphite/render/datalib.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import collections
import re
import time
import types
from six import text_type

from django.conf import settings
Expand Down Expand Up @@ -271,6 +272,13 @@ def prefetchData(requestContext, pathExpressions):
),
))

# Several third-party readers including rrdtool and biggraphite return values in a
# generator which can only be iterated on once. These must be converted to a list.
for pathExpression, items in prefetched.items():
for i, (name, (time_info, values)) in enumerate(items):
if isinstance(values, types.GeneratorType):
prefetched[pathExpression][i] = (name, (time_info, list(values)))

if not requestContext.get('prefetched'):
requestContext['prefetched'] = {}

Expand Down

0 comments on commit 5a904fd

Please sign in to comment.