download timeout vs. socket timeout

P

p.

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?
 
G

Gabriel Genellina

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.
 
M

MRAB

p. said:
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.
 
G

Giampaolo Rodola'

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top