async def METHOD_NAME():
    status = [0, 0]  # num_running, max_running
    async def wait_task(i, delay, status, fail=False):
        status[0] += 1
        await asyncio.sleep(delay)
        status[1] = max(status)
        status[0] -= 1
        if fail:
            raise RuntimeError
        return i
    num_concurrent = random.randint(2, 8)
    num_tasks = random.randint(4 * num_concurrent, 5 * num_concurrent)
    num_fail = random.randint(num_concurrent, num_tasks)
    tasks = [wait_task(i, random.random() / 1000, status) for i in range(num_tasks)]
    tasks += [wait_task(i, random.random() / 1000, status, fail=True) for i in range(num_fail)]
    num_failed = 0
    results = await bounded_gather(*tasks, limit=num_concurrent, return_exceptions=True)
    for i, result in enumerate(results):
        if isinstance(result, RuntimeError):
            num_failed += 1
        else:
            assert result == i  # verify_permissions original order
            assert 0 <= result < num_tasks
    assert 0 < status[1] <= num_concurrent
    assert num_fail == num_failed