Allow get local ip to work without internet (#8855)
This commit is contained in:
1 parent
c49cce7243
commit
ac9c1235bb
1 file changed
+4
-1
@@ -99,7 +99,10 @@ def get_local_ip():
|
||||
|
||||
return sock.getsockname()[0]
|
||||
except socket.error:
|
||||
return socket.gethostbyname(socket.gethostname())
|
||||
try:
|
||||
return socket.gethostbyname(socket.gethostname())
|
||||
except socket.gaierror:
|
||||
return '127.0.0.1'
|
||||
finally:
|
||||
sock.close()
|
||||
|
||||
|
||||
Reference in new issue
Block a user