"torchvision/vscode:/vscode.git/clone" did not exist on "16d62e3072955bd92b76a4ae73fefa73ecc9ee3e"
Unverified Commit 4556fab8 authored by Jinjing Zhou's avatar Jinjing Zhou Committed by GitHub
Browse files

[Fix] Use logging to print warning message in socket creation (#3098)



* fix

* fix

* lint

* fix
Co-authored-by: default avatarQuan (Andy) Gan <coin2028@hotmail.com>
parent 22e8c120
......@@ -3,6 +3,7 @@
import os
import socket
import atexit
import logging
from . import rpc
from .constants import MAX_QUEUE_SIZE
......@@ -13,9 +14,14 @@ if os.name != 'nt':
def local_ip4_addr_list():
"""Return a set of IPv4 address
You can use
`logging.getLogger("dgl-distributed-socket").setLevel(logging.WARNING+1)`
to disable the warning here
"""
assert os.name != 'nt', 'Do not support Windows rpc yet.'
nic = set()
logger = logging.getLogger("dgl-distributed-socket")
for if_nidx in socket.if_nameindex():
name = if_nidx[1]
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
......@@ -25,10 +31,9 @@ def local_ip4_addr_list():
struct.pack('256s', name[:15].encode("UTF-8")))
except OSError as e:
if e.errno == 99: # EADDRNOTAVAIL
print("Warning!",
"Interface: {}".format(name),
"IP address not available for interface.",
sep='\n')
logger.warning(
"Warning! Interface: %s \n"
"IP address not available for interface.", name)
continue
else:
raise e
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment