Python 2.6 ftplib has timeout parameter, but how to detect a timeout

Discussion in 'Python' started by Brendan, Dec 14, 2009.

  1. Brendan

    Brendan Guest

    I was quite happy to see that ftplib in Python 2.6 now has a timeout
    parameter. With large file downloads my script would often hang,
    presumably from timing out. Now that there is a timeout parameter, how
    would I detect when a timeout occurs?
     
    Brendan, Dec 14, 2009
    #1
    1. Advertising

  2. Brendan

    Aahz Guest

    In article <>,
    Brendan <> wrote:
    >
    >I was quite happy to see that ftplib in Python 2.6 now has a timeout
    >parameter. With large file downloads my script would often hang,
    >presumably from timing out. Now that there is a timeout parameter, how
    >would I detect when a timeout occurs?


    Without looking at code or docs, I assume you get an exception.
    --
    Aahz () <*> http://www.pythoncraft.com/

    Weinberg's Second Law: If builders built buildings the way programmers wrote
    programs, then the first woodpecker that came along would destroy civilization.
     
    Aahz, Dec 30, 2009
    #2
    1. Advertising

  3. Re: Python 2.6 ftplib has timeout parameter, but how to detect atimeout

    On 14 Dic, 20:08, Brendan <> wrote:
    > I was quite happy to see that ftplib in Python 2.6 now has a timeout
    > parameter. With large file downloads my script would often hang,
    > presumably from timing out. Now that there is a timeout parameter, how
    > would I detect when a timeout occurs?


    The socket object will raise a timeout exception during recv() or send
    ().


    --- Giampaolo
    http://code.google.com/p/pyftpdlib
     
    Giampaolo Rodola', Dec 30, 2009
    #3
  4. Brendan

    MrJean1 Guest

    Re: Python 2.6 ftplib has timeout parameter, but how to detect atimeout

    Brendan,

    The timeout argument of the FTP class (and the connect method) is used
    only to establish the connection to FTP sockets. If the timeout
    expires, an error called socket.timeout is raised.

    AFAIK, the timeout argument does not limit FTP transfers. To impose a
    time limit on FTP transfers, try using the timelimited function from
    this recipe:

    <http://code.activestate.com/recipes/576780/>

    /Jean



    On Dec 14, 11:08 am, Brendan <> wrote:
    > I was quite happy to see that ftplib in Python 2.6 now has a timeout
    > parameter. With large file downloads my script would often hang,
    > presumably from timing out. Now that there is a timeout parameter, how
    > would I detect when a timeout occurs?
     
    MrJean1, Dec 30, 2009
    #4
  5. Re: Python 2.6 ftplib has timeout parameter, but how to detect atimeout

    On 30 Dic, 18:52, MrJean1 <> wrote:
    > Brendan,
    >
    > The timeout argument of the FTP class (and the connect method) is used
    > only to establish the connection to FTP sockets.  If the timeout
    > expires, an error called socket.timeout is raised.
    >
    > AFAIK, the timeout argument does not limit FTP transfers.  To impose a
    > time limit on FTP transfers, try using the timelimited function from
    > this recipe:
    >
    >  <http://code.activestate.com/recipes/576780/>
    >
    > /Jean
    >
    > On Dec 14, 11:08 am, Brendan <> wrote:
    >
    >
    >
    > > I was quite happy to see that ftplib in Python 2.6 now has a timeout
    > > parameter. With large file downloads my script would often hang,
    > > presumably from timing out. Now that there is a timeout parameter, how
    > > would I detect when a timeout occurs?


    Sorry, I forgot about this.
    I had also opened a ticket for this, a long time ago:
    http://bugs.python.org/issue4814

    --- Giampaolo
    http://code.google.com/p/pyftpdlib
     
    Giampaolo Rodola', Dec 30, 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. Nevyn Twyll
    Replies:
    4
    Views:
    4,407
    Juan T. Llibre
    Mar 19, 2005
  2. Gerrit Holl
    Replies:
    0
    Views:
    920
    Gerrit Holl
    Dec 29, 2003
  3. Jennifer

    ftplib retrlines timeout

    Jennifer, Dec 15, 2009, in forum: Python
    Replies:
    2
    Views:
    521
    Jennifer
    Dec 16, 2009
  4. Nico Grubert

    ftplib timeout in Python 2.4

    Nico Grubert, Dec 17, 2009, in forum: Python
    Replies:
    1
    Views:
    442
  5. Nico Grubert

    Re: ftplib timeout in Python 2.4

    Nico Grubert, Dec 17, 2009, in forum: Python
    Replies:
    2
    Views:
    380
    Nico Grubert
    Dec 18, 2009
Loading...

Share This Page