Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def ping(self, retries=3, **kwargs):
connection = TCPSocketConnection((self.host, self.port))
exception = None
for attempt in range(retries):
try:
pinger = ServerPinger(connection, host=self.host, port=self.port, **kwargs)
pinger.handshake()
return pinger.test_ping()
except Exception as e:
exception = e
else:
raise exception
def status(self, retries=3, **kwargs):
connection = TCPSocketConnection((self.host, self.port))
exception = None
for attempt in range(retries):
try:
pinger = ServerPinger(connection, host=self.host, port=self.port, **kwargs)
pinger.handshake()
result = pinger.read_status()
result.latency = pinger.test_ping()
return result
except Exception as e:
exception = e
else:
raise exception