473,394 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 2940
>>>>> "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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Keith Langer | last post by:
I have an application which consists of a main work thread and multiple threads which each maintain a TCP socket. When a configuration change occurs, all activity on the socket threads must be...
4
by: Jeff | last post by:
I am running a worker thread that manipulates some hardware setting every so often. My problem is that the hardware manipulation cannot be interrupted once it has started How can I ensure that...
7
by: Morris | last post by:
I want to abort a running thread, so I call MyThread.abort() function. My problem is this thread runs "almost" like a while(true) loop and I don't want the Abort() function interrupts the thread at...
20
by: Doug Thews | last post by:
I ran into an interesting re-pain delay after calling the Abort() method on a thread, but it only happens the very first time I call it. Every time afterward, there is no delay. I've got a...
13
by: Andy Fish | last post by:
Hi, I am using COM interop to invoke MS word from my .net app. If word pops up a dialog box, my thread obviously hangs until the dialog is answered. Here's the problem: because the app is...
4
by: am | last post by:
Hi to all. I have a little problem. I'm working with threads, and I need to abort or suspend them, but many experts dissuade from use Thread.Abort and Thread.Suspend. As I didn't find other way,...
3
by: steve | last post by:
Hi All I have a VB.net 2005 app which uses MS Report Viewer to create reports Occassionally I get the following error when changing to a different report User code running on thread 196 has...
12
by: Mangler | last post by:
Does anyone have some good advice for the following situation? If a condition is true, an insert is restricted ( aborted ) otherwise the insert is allowed. I have been killing myself on this for...
1
by: masaniparesh | last post by:
Hi, In my C# program i am termination thread by thread.Abort when times out occur. But i figured out that even after thread.Abort operation the thread is being alive for the random time. I have...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.