Skip to content

Commit 3625e4c

Browse files
author
Panos
committed
Make one result set per chunk for improved performance and API compatibility with non-chunked responses
1 parent ffd1af9 commit 3625e4c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

influxdb/client.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,16 @@ def write(self, data, params=None, expected_response_code=204,
294294
return True
295295

296296
def _read_chunked_response(self, response, raise_errors=True):
297+
result_set = {}
297298
for line in response.iter_lines():
298299
if isinstance(line, bytes):
299300
line = line.decode('utf-8')
300301
data = json.loads(line)
301302
for result in data.get('results', []):
302-
yield ResultSet(result, raise_errors=raise_errors)
303+
for _key in result:
304+
if type(result[_key]) == list:
305+
result_set.setdefault(_key, []).extend(result[_key])
306+
return ResultSet(result_set, raise_errors=raise_errors)
303307

304308
def query(self,
305309
query,
@@ -330,8 +334,8 @@ def query(self,
330334
:type raise_errors: bool
331335
332336
:param chunked: Enable to use chunked responses from InfluxDB.
333-
With ``chunked`` enabled, a _generator_ of ResultSet objects
334-
is returned as opposed to a list.
337+
With ``chunked`` enabled, one ResultSet is returned per chunk
338+
containing all results within that chunk
335339
:type chunked: bool
336340
337341
:param chunk_size: Size of each chunk to tell InfluxDB to use.

0 commit comments

Comments
 (0)