Keeping a function from taking to long--threads?

Steve Holden steve at holdenweb.com
Mon Mar 20 05:08:43 EST 2006


brandon.mcginty at gmail.com wrote:
> Thanks, however, I forgot to mention that I'm using windows, and from what
> I've tried, the setdefaulttimeout function doesn't work on my machine.
> Again, thanks for your help!
> Brandon McGinty
> 
What version of Python are you running? Under 3.4 setdefaulttimeout() 
works perfectly well on my Windows system.

If you are running 2.3 or earlier, you may want to use Timothy 
O'Malley's timeoutsocket module instead.

However, you seem to be assuming that socket.gethostbyaddr() will report 
on the existence of systems, which I don't think it will - that function 
is for converting IP addresses to names:

  >>> import socket
  >>> socket.gethostbyaddr("127.0.0.1")
('localhost', [], ['127.0.0.1'])
  >>> socket.gethostbyaddr("192.168.10.215")
('bigboy.lan', [], ['192.168.10.215'])
  >>> socket.gethostbyaddr("82.165.194.52")
('perfora.net', [], ['82.165.194.52'])
  >>>

So it will tell you something about the DNS service's content rather 
than the existence or non-existence of systems at a particular IP address.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd                 www.holdenweb.com
Love me, love my blog         holdenweb.blogspot.com




More information about the Python-list mailing list