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

Changes batching to allow all iterables #408

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
7 changes: 5 additions & 2 deletions influxdb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from __future__ import print_function
from __future__ import unicode_literals

import itertools
import json
import socket
import requests
Expand Down Expand Up @@ -411,8 +412,10 @@ def write_points(self,
tags=tags, protocol=protocol)

def _batches(self, iterable, size):
for i in xrange(0, len(iterable), size):
yield iterable[i:i + size]
iterator = iter(iterable)
while True:
batch_iterator = itertools.islice(iterator, size)
yield itertools.chain([next(batch_iterator)], batch_iterator)

def _write_points(self,
points,
Expand Down