Invoked by the IOLoop, this method checks if the HTTP request future
    created by :meth:`_write_error_batch` is done. If it's done it will
    evaluate the result, logging any error and moving on to the next
    measurement. If there are no measurements left in the `measurements`
    argument, it will consider the batch complete.


    :param tornado.concurrent.Future future: The AsyncHTTPClient request future
    :param str batch: The batch ID
    :param str database: The database name for the measurements
    :param str measurement: The measurement the future is for
    :param list measurements: The measurements that failed to write as a batch

def _write_error_batch_wait(future, batch, database, measurement,
                            measurements):
    """Invoked by the IOLoop, this method checks if the HTTP request future
    created by :meth:`_write_error_batch` is done. If it's done it will
    evaluate the result, logging any error and moving on to the next
    measurement. If there are no measurements left in the `measurements`
    argument, it will consider the batch complete.


    :param tornado.concurrent.Future future: The AsyncHTTPClient request future
    :param str batch: The batch ID
    :param str database: The database name for the measurements
    :param str measurement: The measurement the future is for
    :param list measurements: The measurements that failed to write as a batch

    """
    if not future.done():
        ioloop.IOLoop.current().add_timeout(
            ioloop.IOLoop.current().time() + 0.025,
            _write_error_batch_wait, future, batch, database, measurement,
            measurements)
        return

    error = future.exception()
    if isinstance(error, httpclient.HTTPError):
        if error.code == 400:
            LOGGER.error('Error writing %s measurement from batch %s to '
                         'InfluxDB (%s): %s', database, batch, error.code,
                         error.response.body)
            LOGGER.info('Bad %s measurement from batch %s: %s',
                        database, batch, measurement)
        else:
            LOGGER.error('Error submitting individual metric for %s from '
                         'batch %s to InfluxDB (%s): %s',
                         database, batch, error.code)
            measurements = measurements + [measurement]
    elif isinstance(error, (TimeoutError, OSError, socket.error,
                            select.error, ssl.socket_error)):
        LOGGER.error('Error submitting individual metric for %s from batch '
                     '%s to InfluxDB (%s)', database, batch, error)
        _write_error_batch(batch, database, measurements + [measurement])
        measurements = measurements + [measurement]

    if not measurements:
        LOGGER.info('All %s measurements from batch %s processed',
                    database, batch)
        return

    # Continue writing measurements
    _write_error_batch(batch, database, measurements)