Skip to content

Commit

Permalink
Flusher functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
twstokes committed Jun 16, 2018
1 parent 9fe4bc0 commit 88f1d64
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions healthdata_influx/import.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def parse_and_upload(self, export_path):
Uploads to InfluxDB
"""

def create_flusher(buffer, size, records):
def flusher():
def create_flusher(buffer, size):
def flusher(records):
print("Flushing {} points to DB. Current total: {}".format(size, records))
self.upload(buffer[:size])
# clean up
Expand All @@ -51,7 +51,7 @@ def flusher():

point_buffer = []
total_records, success_records = (0, 0)
flusher = create_flusher(point_buffer, self.buffer_size, total_records)
flusher = create_flusher(point_buffer, self.buffer_size)

for idx, (_, record) in enumerate(context):
total_records += 1
Expand All @@ -64,7 +64,7 @@ def flusher():
output_mung_error(error, record, idx+1)

if len(point_buffer) > self.buffer_size - 1:
flusher()
flusher(total_records)

# memory cleanup
record.clear()
Expand Down

0 comments on commit 88f1d64

Please sign in to comment.