Handle a batch submission error, logging the problem and adding the
    measurements back to the stack.

    :param str batch: The batch ID
    :param mixed error: The error that was returned
    :param str database: The database the submission failed for
    :param list measurements: The measurements to add back to the stack

def _on_5xx_error(batch, error, database, measurements):
    """Handle a batch submission error, logging the problem and adding the
    measurements back to the stack.

    :param str batch: The batch ID
    :param mixed error: The error that was returned
    :param str database: The database the submission failed for
    :param list measurements: The measurements to add back to the stack

    """
    LOGGER.info('Appending %s measurements to stack due to batch %s %r',
                database, batch, error)
    _measurements[database] = _measurements[database] + measurements