@nadine.benharrath
It has been a long time since I worked on multi-thread or async, but I got a few ideas. They will need your help cleaning up, as I am out of practice.
Refactor the for claim in getclaims(data):
into a generator. If I recall correctly, a generator in python is kind of like an iterable, but masks how many items there are, and produces one item each call.
Replace the loops with
event_data_batch = await producer.create_batch() #instantiate first batch
send_time = time.now + 60 #set time to send first batch 1 minute in the future
while (record = generate_claim) is not null: #get a claim, break loop if no more claims to get
event_data_batch.add(record)
if time.now > send_time: #if enough time has passed,
await producer.send_batch(event_data_batch) #send the batch!
event_data_batch = await producer.create_batch() #clear out and create new batch for the next loop