[Pythonmac-SIG] socket.getaddrinfo problems

Bob Ippolito bob at redivi.com
Thu Apr 15 19:56:44 EDT 2004


On Apr 15, 2004, at 7:39 PM, Craig Amundsen wrote:

>
> On Apr 15, 2004, at 4:25 PM, Steven Palm wrote:
>
>> On Apr 15, 2004, at 5:39 PM, Dudley Carr wrote:
>>> I've run the code snippet below several times on different domains 
>>> with the same results. Can anyone else confirm the timings that I'm 
>>> getting below?
>>>
>>> >>>import socket,time
>>> >>> def getaddrinfoTest(count):
>>> ...     for i in range(count):
>>> ...             start = time.time()
>>> ...             socket.getaddrinfo('yahoo.com', 80)
>>> ...             end = time.time()
>>> ...             print 'time =', end - start

Basically the fact that this call takes any real time at all means that 
you should definitely be doing your own DNS caching, or find another 
way to do it that does.

In any case, your application is definitely a good candidate for 
rewrite in Twisted.  Using Twisted will abstract away all of the lower 
level details of cross-platform socket programming and make your 
application more efficient/responsive so long as you can drink the 
event driven kool-aid.

-bob




More information about the Pythonmac-SIG mailing list