When doing very regular updates of big amounts of members it turns out batch operations aren't a good fit. This release adds functionality to do 'batch' updates using `POST` calls on the `/lists/<list_id>` endpoint directly. This means connections to mailchimp remain open longer but there's a guarantee that everything gets processed in the correct order. Tests show that to create/update a batch of 250 000 members takes about 20-25 minutes this way.
If you want to be able to follow the progress of these updates it's possible to pass a callback function. This should be a generator looking something like this:
python
def callback():
try:
while True:
progress = yield
this will yield namedtuple 'ProgressStatus' with following data: id (batch id), total (total batch size), completed, last_response_status
do stuff with progress here
finally:
do stuff that needs to be done after update is finished, handle success, errors,...
Some more insights about mailchimp batch operations and when to use or not use them I've gotten after communication with a few very helpful mailchimp support people:
>Batches work best we they are submitted one at a time, and are allowed to finish running before the next batch is submitted. Because of this, batches are good for when you need to update or retrieve information semi-regularly.
>Individual operations within batches are processed randomly. Additionally, if you submit smaller batches while a large batch is processing, the smaller batches would get picked up in the middle of the large batch.
This means that attempting to pass smaller batches while a large batch is running can cause for the small batches to complete first, or even cause for the large batch to timeout before it has finished.