download timeout vs. socket timeout

Discussion in 'Python' started by p., Jan 10, 2009.

  1. p.

    p. Guest

    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?
    p., Jan 10, 2009
    #1
    1. Advertising

  2. En Sat, 10 Jan 2009 00:07:15 -0200, p. <> 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
    Gabriel Genellina, Jan 10, 2009
    #2
    1. Advertising

  3. p.

    MRAB Guest

    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.
    MRAB, Jan 10, 2009
    #3
  4. On 10 Gen, 03:07, "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?


    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
    Giampaolo Rodola', Jan 10, 2009
    #4
  5. Giampaolo Rodola', Jan 10, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laszlo Nagy
    Replies:
    1
    Views:
    4,766
    Mark Wooding
    Jan 27, 2009
  2. Jean-Paul Calderone
    Replies:
    0
    Views:
    948
    Jean-Paul Calderone
    Jan 27, 2009
  3. Laszlo Nagy
    Replies:
    0
    Views:
    531
    Laszlo Nagy
    Feb 1, 2009
  4. Steve Holden
    Replies:
    0
    Views:
    648
    Steve Holden
    Feb 1, 2009
  5. Mark Probert

    Timeout::timeout and Socket timeout

    Mark Probert, Oct 6, 2004, in forum: Ruby
    Replies:
    1
    Views:
    1,269
    Brian Candler
    Oct 6, 2004
Loading...

Share This Page