mirror of https://github.com/hpcaitech/ColossalAI
[cli] fixed hostname mismatch error (#2465)
parent
c20529fe78
commit
14d9299360
|
@ -1,5 +1,5 @@
|
|||
from typing import List
|
||||
import socket
|
||||
from typing import List
|
||||
|
||||
|
||||
class HostInfo:
|
||||
|
@ -35,9 +35,14 @@ class HostInfo:
|
|||
|
||||
if port is None:
|
||||
port = 22 # no port specified, lets just use the ssh port
|
||||
hostname = socket.getfqdn(hostname)
|
||||
|
||||
# socket.getfqdn("127.0.0.1") does not return localhost
|
||||
# on some users' machines
|
||||
# thus, we directly return True if hostname is locahost, 127.0.0.1 or 0.0.0.0
|
||||
if hostname in ("localhost", "127.0.0.1", "0.0.0.0"):
|
||||
return True
|
||||
|
||||
hostname = socket.getfqdn(hostname)
|
||||
localhost = socket.gethostname()
|
||||
localaddrs = socket.getaddrinfo(localhost, port)
|
||||
targetaddrs = socket.getaddrinfo(hostname, port)
|
||||
|
|
Loading…
Reference in New Issue