def METHOD_NAME(project, target_region, source_instance, name, wait=True):
    try:
        waited_time = RATE_LIMIT.wait()  # wait before starting the task
        logging.info('  task: waited for %s secs', waited_time)
        logging.info('Creating Machine Image %s from source %s', name,
                     source_instance)
        compute = get_compute()
        machine_image(compute, project, target_region, source_instance, name)
        if wait:
            wait_for_operation(compute, project, name)
        logging.info('Machine Image %s Created', name)
        return name
    except Exception as exc:
        logging.error(exc)
        raise exc