Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Properly use chunk_size param #523

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions influxdb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,13 @@ def write(self, data, params=None, expected_response_code=204,
return True

@staticmethod
def _read_chunked_response(response, raise_errors=True):
def _read_chunked_response(
response,
raise_errors=True,
chunk_size=requests.models.ITER_CHUNK_SIZE):

result_set = {}
for line in response.iter_lines():
for line in response.iter_lines(chunk_size=chunk_size):
if isinstance(line, bytes):
line = line.decode('utf-8')
data = json.loads(line)
Expand All @@ -339,7 +343,7 @@ def query(self,
database=None,
raise_errors=True,
chunked=False,
chunk_size=0):
chunk_size=requests.models.ITER_CHUNK_SIZE):
"""Send a query to InfluxDB.

:param query: the actual query string
Expand Down Expand Up @@ -387,8 +391,7 @@ def query(self,

if chunked:
params['chunked'] = 'true'
if chunk_size > 0:
params['chunk_size'] = chunk_size
params['chunk_size'] = chunk_size

response = self.request(
url="query",
Expand All @@ -399,7 +402,10 @@ def query(self,
)

if chunked:
return self._read_chunked_response(response)
return self._read_chunked_response(
response,
chunk_size=params['chunk_size']
)

data = response.json()

Expand Down