def _set_master_addr_port(store: Store, master_addr: Optional[str], master_port: Optional[int]): if master_port is None: sock = _get_socket_with_port() with closing(sock): master_port = sock.getsockname()[1] if master_addr is None: master_addr = _get_fq_hostname() store.set("MASTER_ADDR", master_addr.encode(encoding="UTF-8")) store.set("MASTER_PORT", str(master_port).encode(encoding="UTF-8"))
def _set_master_addr_port(store: Store, master_addr: Optional[str], master_port: Optional[int]): if master_port is None: sock = _get_socket_with_port() with closing(sock): master_port = sock.getsockname()[1] if master_addr is None: # master_addr = _get_fq_hostname() result = subprocess.check_output("hostname -I", shell=True) master_addr = result.decode('utf-8').split()[0] store.set("MASTER_ADDR", master_addr.encode(encoding="UTF-8")) store.set("MASTER_PORT", str(master_port).encode(encoding="UTF-8"))
def _get_master_addr_port(store: Store) -> Tuple[str, int]: master_addr = store.get("MASTER_ADDR").decode(encoding="UTF-8") master_port = int(store.get("MASTER_PORT").decode(encoding="UTF-8")) return (master_addr, master_port)