def _yield_obj()

in mobile_cv/common/misc/iter_utils.py [0:0]


def _yield_obj(obj, wait_on_send: bool, yield_name: bool, name_prefix: str):
    ret = obj
    yield_obj = obj if not yield_name else (name_prefix, obj)
    cret = yield yield_obj
    # data sent back to `ret`, needs a yield for `send()` to pause here as
    #   both 'send()' and `for` advances the generator
    if wait_on_send is True:
        ret = cret
        yield
    elif wait_on_send is False:
        pass
    else:  # for backward compatbility
        assert wait_on_send is None
        # cret is not None means user calls `send`, it could not distingush
        #   the case that user sends None
        if cret is not None:
            ret = cret
            yield
    return ret  # noqa