Closed LarsNorgaard closed 5 years ago
Hi Lars,
You can specify a region with the -r
flag-- the options are us
, int
(for non-US), and all
. pypia uses US by default. As an example, you could do:
pypia -r all -p
which should tabulate the average of 3 pings to each pia server worldwide.
I'm not sure about those exceptions-- can you tell me more about those?
Thanks
Yeah, but when I run that command I get those errors. Works fine if I ping the US servers. Could it be that some of the servers are down, so the script gets an 404 and errors out?
Interesting. That's possible. I will look into it this evening. Thanks for reporting it!
I have not been able to reproduce the error. Are you able to ping those IP addresses directly? In other words, from the terminal, for example ping 108.61.122.217
Just tried pinging some of the IP's and some packet loss is happening. Guess it could be my network or my router borking up.
--- 177.154.139.203 ping statistics ---
22 packets transmitted, 20 received, 9% packet loss, time 21052ms
rtt min/avg/max/mdev = 239.779/240.049/240.334/0.266 ms
Not too sure if that could be why I get those python errors?
Might be-- in any case I should probably add some code to deal with uncooperative endpoints so that the program doesn't error out when there's a problem pinging one of the servers.
I have had the same problem. I live in Denmark and primarily uses european servers. Using pypia -r int -f
or pypia -r int -p
causes pypia to crash, if one of the servers are down. I solved it by adding a few lines of code to the ping method
in the latencies class
so the ping method
now looks like this:
def ping(self):
ip = self.q.get()
try:
result = subprocess.check_output(['ping', '-c', '3', ip]).decode('utf-8')
except subprocess.CalledProcessError:
self.q.task_done()
return
avg = float(result.split('=')[-1].split('/')[1])
self.latencies[ip] = avg
self.q.task_done()
I'm sure it can be done more eleganly, but it works for me. /Saltani
@Saltani, this is great, thank you for debugging and submitting a workaround. I like the try/except to catch the CalledProcessError exception.
One thing I'd like to do is somehow notify the user that one of the endpoints failed. I think what I'll do instead of marking self.q.task_done()
in the except block, I'll assign the avg
for that ip to an arbitrarily high latency time, so that it is obvious that the ping failed for that endpoint, and so it will still get recorded in the latencies table.
fixed with 6099c5efb99f46c287721d4cb0381f1d658dd247
updated version on pypi to 0.3.6
Good solution. Works nicely, thanks a lot :-)
Seems like I'm only able to ping and list the US servers and not the rest?