def get_hostname(host=None):
    if host is None:
        host = socket.gethostname()
    try:
        return socket.gethostbyaddr(host)[0]
    except socket.herror: # DNS CAN'T RESOLVE HOSTNAME
        return host # JUST USE HOSTNAME AS REPORTED BY gethostname()
get FQDN for host, or current host if not specified
dataset/ETHPy150Open cjlee112/pygr/pygr/coordinator.py/get_hostname