469,929 Members | 1,889 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,929 developers. It's quick & easy.

How to abort a ftp operation

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.
Jul 18 '05 #1
1 2842
>>>>> "Lothar" == Lothar Scholz <du***@scriptolutions.com> 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
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Keith Langer | last post: by
4 posts views Thread by Jeff | last post: by
7 posts views Thread by Morris | last post: by
20 posts views Thread by Doug Thews | last post: by
13 posts views Thread by Andy Fish | last post: by
4 posts views Thread by am | last post: by
12 posts views Thread by Mangler | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.