Skip to content

Commit

Permalink
Fix address.split for ipv6
Browse files Browse the repository at this point in the history
Because ipv6 ip has multiple ':'
  • Loading branch information
frostyplanet committed Jul 14, 2024
1 parent 204e67b commit 3320bd3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions python/xoscar/backends/communication/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ async def create(config: Dict) -> "Server":
config = config.copy()
if "address" in config:
address = config.pop("address")
host, port = address.split(":", 1)
host, port = address.rsplit(":", 1)
port = int(port)
else:
host = config.pop("host")
Expand Down Expand Up @@ -250,7 +250,7 @@ class SocketClient(Client):
async def connect(
dest_address: str, local_address: str | None = None, **kwargs
) -> "Client":
host, port_str = dest_address.split(":", 1)
host, port_str = dest_address.rsplit(":", 1)
port = int(port_str)
(reader, writer) = await asyncio.open_connection(host=host, port=port, **kwargs)
channel = SocketChannel(
Expand Down
4 changes: 2 additions & 2 deletions python/xoscar/backends/communication/ucx.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ async def create(config: Dict) -> "Server":
prefix = f"{UCXServer.scheme}://"
if address.startswith(prefix):
address = address[len(prefix) :]
host, port = address.split(":", 1)
host, port = address.rsplit(":", 1)
port = int(port)
else:
host = config.pop("host")
Expand Down Expand Up @@ -498,7 +498,7 @@ async def connect(
prefix = f"{UCXClient.scheme}://"
if dest_address.startswith(prefix):
dest_address = dest_address[len(prefix) :]
host, port_str = dest_address.split(":", 1)
host, port_str = dest_address.rsplit(":", 1)
port = int(port_str)
kwargs = kwargs.copy()
ucx_config = kwargs.pop("config", dict()).get("ucx", dict())
Expand Down
2 changes: 1 addition & 1 deletion python/xoscar/backends/indigen/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def get_external_addresses(
"""Get external address for every process"""
assert n_process is not None
if ":" in address:
host, port_str = address.split(":", 1)
host, port_str = address.rsplit(":", 1)
port = int(port_str)
if ports:
if len(ports) != n_process:
Expand Down
2 changes: 1 addition & 1 deletion python/xoscar/collective/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def backend(self) -> str:
return self._backend

def _get_ip(self) -> str:
return self.address.split(":")[0]
return self.address.rsplit(":", 1)[0]

def _process_group_name(self, ranks: List[int]) -> str:
return hashlib.sha1(
Expand Down

0 comments on commit 3320bd3

Please sign in to comment.