Flush all pending measurements to InfluxDB. This will ensure that all
    measurements that are in the buffer for any database are written. If the
    requests fail, it will continue to try and submit the metrics until they
    are successfully written.

    :rtype: :class:`~tornado.concurrent.Future`

def flush():
    """Flush all pending measurements to InfluxDB. This will ensure that all
    measurements that are in the buffer for any database are written. If the
    requests fail, it will continue to try and submit the metrics until they
    are successfully written.

    :rtype: :class:`~tornado.concurrent.Future`

    """
    flush_future = concurrent.Future()
    if _batch_future and not _batch_future.done():
        LOGGER.debug('Flush waiting on incomplete _batch_future')
        _flush_wait(flush_future, _batch_future)
    else:
        LOGGER.info('Flushing buffer with %i measurements to InfluxDB',
                    _pending_measurements())
        _flush_wait(flush_future, _write_measurements())
    return flush_future