def is_loop_running(loop):
    """
    Return whether an IOLoop is running. (Stolen from Dask)
    """
    r = getattr(loop, '_running', None)
    if r is not None:
        return r
    try:
        return loop.asyncio_loop.is_running()
    except AttributeError:
        raise TypeError("don't know how to query the running state of %s" %
            (type(loop),))
