send batches of at most 10 heartbeats to api

This commit is contained in:
Alan Hamlett 2018-09-20 10:14:25 -07:00
parent 8809c55765
commit b488cd537c
3 changed files with 12 additions and 9 deletions

View file

@ -66,8 +66,7 @@ def execute(argv=None):
retval = send_heartbeats(heartbeats, args, configs)
if retval == SUCCESS:
queue = Queue(args, configs)
offline_heartbeats = queue.pop_many(args.sync_offline_activity)
if len(offline_heartbeats) > 0:
for offline_heartbeats in queue.pop_many(args.sync_offline_activity):
retval = send_heartbeats(offline_heartbeats, args, configs)
return retval

View file

@ -115,8 +115,12 @@ class Queue(object):
break
heartbeats.append(heartbeat)
count += 1
if count % 10 == 0:
yield heartbeats
heartbeats = []
return heartbeats
if heartbeats:
yield heartbeats
def _get_db_file(self):
home = '~'