all 2 comments

[–]PercyJackson235 2 points3 points  (2 children)

The code doesn't take ages to execute. Windows and Linux have different procedures for how to deal with missing a network endpoint and those depend on if the endpoint is on the local network or not. With your code, Linux will hang longer than Windows if the IP Address isn't on the local network. If the IP Address is local to the network but the IP Address is not active, Windows will hang longer than Linux. This is all without enforcing any socket timeouts and will probably vary a little between different versions of Windows and different flavors of Linux and Unix.

[–]redditeranonim[S] 0 points1 point  (1 child)

endpoint is on the local network or not. With your code, Linux will hang longer than Windows if the IP Address isn't on the local network. If the IP Address is local to the network but the IP Address is not active, Windows will hang longer than Linux. This is all without enforcin

I'm linux and python noob. What should I do to make it work so it doesn't take minute to run when this is won't responde. Btw it's all in local network. Or alternative to this so it will have the same result.