import ping3 def ping(host: str) -> int: """ Pings the given host and returns the time the ping took ins ms or -1 if the ping was not successful :param host: :return: """ res = ping3.ping(dest_addr=host, unit='ms') if res: return int(res) else: return -1