How to abort a ftp operation

L

Lothar Scholz

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

Ville Vainio

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()..
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top