@tornado.gen.coroutine
def async_poll_for(filename, needles, timeout=5):
    if isinstance(needles, str):
        needles = [needles]

    start = time()
    needle = content = None
    while time() - start < timeout:
        with open(filename) as f:
            content = f.read()
        for needle in needles:
            if needle in content:
                raise tornado.gen.Return(True)
        yield tornado_sleep(0.1)
    raise TimeoutException('Timeout polling "%s" for "%s". Content: %s' % (
        filename, needle, content))
Async version of poll_for
dataset/ETHPy150Open circus-tent/circus/circus/tests/support.py/async_poll_for