How to wait only so long for a server to respond?

Paul Clinch pclinch at internet-glue.co.uk
Wed Apr 3 16:42:51 EST 2002


Ralph <ralph at penguin.com> wrote in message news:<n1Dq8.12893$ml2.1014180 at newsread1.prod.itd.earthlink.net>...
> Sean 'Shaleh' Perry wrote:
> 
> > 
> > On 03-Apr-2002 Ralph wrote:
> >> Pythoners:
> >> 
> >> I have some code that requests a response from a server on the Internet,
> >> but I only want to wait so long for the server to respond.  How can I
> >> tell python to wait x seconds/minutes, then move on to the next section
> >> of code if the server has not responded?
> >> 
> >> Thanks as always.
> >> 
> > 
> > a select loop is a common way to wait for data on a socket and specify a
> > timeout.  Look for documentation on select().
> Sean:
> 
> Thanks for the hint.  I'll take a look.
> 
> Ralph

You can also try timeoutsocket.py from the vaults of Parnassus.
I have used it with 1.52 successfuly.

Paul



More information about the Python-list mailing list