Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > download timeout vs. socket timeout

Reply
Thread Tools

download timeout vs. socket timeout

 
 
p.
Guest
Posts: n/a
 
      01-10-2009
i'm using urllib2 in python 2.4

wondering how people typically deal with the case in which a download
is too slow. setting the socket timeout only covers those cases where
there is no response in the socket for whatever the timeout period is.
what if, however, i'm getting bits back but want simply to bail out if
the total time to download takes too long?

i'm trying to avoid creating a whole other thread if possible?
 
Reply With Quote
 
 
 
 
Gabriel Genellina
Guest
Posts: n/a
 
      01-10-2009
En Sat, 10 Jan 2009 00:07:15 -0200, p. <(E-Mail Removed)> escribió:

> i'm using urllib2 in python 2.4
>
> wondering how people typically deal with the case in which a download
> is too slow. setting the socket timeout only covers those cases where
> there is no response in the socket for whatever the timeout period is.
> what if, however, i'm getting bits back but want simply to bail out if
> the total time to download takes too long?
>
> i'm trying to avoid creating a whole other thread if possible?


You may use signal.alarm if it is available on your platform.
On Windows, using a separate thread for reading is the easiest option -
unless you plan to download hundreds of files simultaneously.

--
Gabriel Genellina

 
Reply With Quote
 
 
 
 
MRAB
Guest
Posts: n/a
 
      01-10-2009
p. wrote:
> i'm using urllib2 in python 2.4
>
> wondering how people typically deal with the case in which a download
> is too slow. setting the socket timeout only covers those cases where
> there is no response in the socket for whatever the timeout period is.
> what if, however, i'm getting bits back but want simply to bail out if
> the total time to download takes too long?
>
> i'm trying to avoid creating a whole other thread if possible?
>

Don't try to download all the data in one go, but do it a chunk at a
time. If you calculate that it would take too long to complete, then stop.
 
Reply With Quote
 
Giampaolo Rodola'
Guest
Posts: n/a
 
      01-10-2009
On 10 Gen, 03:07, "p." <(E-Mail Removed)> wrote:
> i'm using urllib2 in python 2.4
>
> wondering how people typically deal with the case in which a download
> is too slow. setting the socket timeout only covers those cases where
> there is no response in the socket for whatever the timeout period is.
> what if, however, i'm getting bits back but want simply to bail out if
> the total time to download takes too long?
>
> i'm trying to avoid creating a whole other thread if possible?


You could retrieve your file in little parts and at the same time have
a thread which checks how many bytes have been transmitted every
second.


--- Giampaolo
http://code.google.com/p/pyftpdlib
 
Reply With Quote
 
Giampaolo Rodola'
Guest
Posts: n/a
 
      01-10-2009
I'm sorry. I realized they had already replied when it was too late.


--- Giampaolo
http://code.google.com/p/pyftpdlib
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Steve Holden Python 0 02-01-2009 12:45 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 0 02-01-2009 07:37 AM
socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 1 01-27-2009 05:05 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48,'Address already in use') Jean-Paul Calderone Python 0 01-27-2009 01:41 PM
Timeout::timeout and Socket timeout Mark Probert Ruby 1 10-06-2004 09:30 AM



Advertisments