How to abort a ftp operation

Ville Vainio ville at
Tue Jul 6 12:12:15 CEST 2004

>>>>> "Lothar" == Lothar Scholz <dummy at> 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. 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

More information about the Python-list mailing list