@gen.coroutine
def yield_for_all_futures(result):
    while True:
        try:
            future = gen.convert_yielded(result)
        except gen.BadYieldError:
            # result is not a yieldable thing, we are done
            break
        else:
            result = yield future
    raise gen.Return(result)
Converts result into a Future by collapsing any futures inside result.
dataset/ETHPy150Open bokeh/bokeh/bokeh/util/tornado.py/yield_for_all_futures