import asyncio


async def open_port(host, port):
    """Repeatedly try if a port on a host is open until duration seconds passed

    Parameters
    ----------
    host : str
        Host IP address or hostname
    port : int
        Port number

    Returns
    -------
    awaitable bool
    """
    try:
        _reader, writer = await asyncio.wait_for(
            asyncio.open_connection(host, port), timeout=2
        )
        writer.close()
        await writer.wait_closed()
        return True
    except Exception:
        pass

    return False