'This function is only called when sender is closed forcefully. It will fail all the
incomplete batches and return.'

def abort_incomplete_batches(self):

    while True:
        self._abort_batches()
        if (not self._appends_in_progress.get()):
            break
    self._abort_batches()
    self._batches.clear()
