Non-blocking connect BLOCKS

jtd adwser at hotmail.com
Wed Apr 28 10:42:25 EDT 2004


"Dave Brueck" <dave at pythonapocrypha.com> wrote in message news:<mailman.50.1083086460.25742.python-list at python.org>...
> > I'm using asyncore to download a large list of web pages, and I've
> > noticed dispatcher.connect blocks for some hosts. I was under the
> > impression that non-blocking sockets do not block on connects, in
> > addition to reads and writes. My connect code is essentially the same
> > as the asyncore example:
> >
> > http://docs.python.org/lib/asyncore-example.html
> >
> > It seems unlikely that I am the first to encounter this problem, can
> > someone explain what's wrong and suggest a remedy?
> 
> Most likely the connect call is doing a DNS lookup, which means your execution
> pauses while some other (non-Python) code goes and talks to the DNS server. 

Thank you, that was exactly the problem. Instead of messing around
with DNS lookup protocols, I rewrote the program using threads. Now
the lookups take O(1) rather than O(number of threads/user threads)
time :)



More information about the Python-list mailing list