Coder Social home page Coder Social logo

Not able to ping all servers about pypia HOT 10 CLOSED

dagrha avatar dagrha commented on August 15, 2024
Not able to ping all servers

from pypia.

Comments (10)

dagrha avatar dagrha commented on August 15, 2024 1

Interesting. That's possible. I will look into it this evening. Thanks for reporting it!

from pypia.

dagrha avatar dagrha commented on August 15, 2024

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

from pypia.

LarsNorgaard avatar LarsNorgaard commented on August 15, 2024

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?

from pypia.

dagrha avatar dagrha commented on August 15, 2024

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

from pypia.

LarsNorgaard avatar LarsNorgaard commented on August 15, 2024

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?

from pypia.

dagrha avatar dagrha commented on August 15, 2024

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.

from pypia.

Saltani avatar Saltani commented on August 15, 2024

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

from pypia.

dagrha avatar dagrha commented on August 15, 2024

@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.

from pypia.

dagrha avatar dagrha commented on August 15, 2024

fixed with 6099c5e

updated version on pypi to 0.3.6

from pypia.

Saltani avatar Saltani commented on August 15, 2024

Good solution. Works nicely, thanks a lot :-)

image

from pypia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.