def METHOD_NAME(
        port_number: int, tries: int = 10, sleep: float = 0.1, pid: Optional[int] = None,
) -> None:
    if pid is None:
        pid = os.getpid()
    for _ in range(tries):
        gevent.sleep(sleep)
        # macoOS requires root access for the connections api to work
        # so get connections of the current process only
        connections = psutil.Process(pid).connections()
        for conn in connections:
            if conn.status == 'LISTEN' and conn.laddr[1] == port_number:
                return
    raise RuntimeError(f'{port_number} is not bound')