How to abort a ftp operation

Discussion in 'Python' started by Lothar Scholz, Jul 6, 2004.

  1. Hello,

    i use the ftplib to do some tasks and my GUI offers an "Abort" button
    to stop but unfortunately there is no general way to stop the ftp
    asynchronously from another thread. Is it possible to simply close the
    socket handle from another thread, which should result in some kind of
    protocol error on the ftp client.

    Please don't tell me i must let my customers wait. Connect timeouts
    can be very long.
    Lothar Scholz, Jul 6, 2004
    #1
    1. Advertising

  2. Lothar Scholz

    Ville Vainio Guest

    >>>>> "Lothar" == Lothar Scholz <> writes:


    Lothar> asynchronously from another thread. Is it possible to
    Lothar> simply close the socket handle from another thread, which
    Lothar> should result in some kind of protocol error on the ftp
    Lothar> client.

    ftplib.py has the following method in FTP class:

    def abort(self):
    '''Abort a file transfer. Uses out-of-band data.
    This does not follow the procedure from the RFC to send Telnet
    IP and Synch; that doesn't seem to work with the servers I've
    tried. Instead, just send the ABOR command as OOB data.'''
    line = 'ABOR' + CRLF
    if self.debugging > 1: print '*put urgent*', self.sanitize(line)
    self.sock.sendall(line, MSG_OOB)
    resp = self.getmultiline()
    if resp[:3] not in ('426', '226'):
    raise error_proto, resp

    Try that, or just do ftpobject.sock.close()..

    --
    Ville Vainio http://tinyurl.com/2prnb
    Ville Vainio, Jul 6, 2004
    #2
    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. david ullua
    Replies:
    13
    Views:
    666
  2. Replies:
    2
    Views:
    303
  3. raan
    Replies:
    2
    Views:
    450
  4. Mangler

    Abort an operation

    Mangler, Jan 15, 2007, in forum: ASP General
    Replies:
    11
    Views:
    225
    Mangler
    Jan 18, 2007
  5. D. Buck
    Replies:
    2
    Views:
    482
    D. Buck
    Jun 29, 2004
Loading...

Share This Page