'The main run loop for the sender thread.'

def run(self):

    log.debug('Starting    Kafka    producer    I/O    thread.')
    while self._running:
        try:
            self.run_once()
        except Exception:
            log.exception('Uncaught    error    in    kafka    producer    I/O    thread')
    log.debug('Beginning    shutdown    of    Kafka    producer    I/O    thread,    sending    remaining    records.')
    while ((not self._force_close) and (self._accumulator.has_unsent() or (self._client.in_flight_request_count() > 0))):
        try:
            self.run_once()
        except Exception:
            log.exception('Uncaught    error    in    kafka    producer    I/O    thread')
    if self._force_close:
        self._accumulator.abort_incomplete_batches()
    try:
        self._client.close()
    except Exception:
        log.exception('Failed    to    close    network    client')
    log.debug('Shutdown    of    Kafka    producer    I/O    thread    has    completed.')
