Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > ftp design question

Reply
Thread Tools

ftp design question

 
 
nemo
Guest
Posts: n/a
 
      12-29-2008
Hi,all.
I'm on a toy ftp project and I want it to be convinient for the user
to cancel an undergoing downloading while continue others. The
following code explains:
for file in download_files:
self.ftp.retrbinary('RETR '+file, fileHandler)
Thers seems not a solid way to cancel this transfer and I considered
thread or process but I can't handle this correctly.
Thread: I can't kill the thread in another thread, so...
Process: There seems something wrong(raise an EOFError exception) when
I use Process(target = download_fun, args = (dir,)) for each
downloading after connection built.
Some suggestions?
 
Reply With Quote
 
 
 
 
Steve Holden
Guest
Posts: n/a
 
      12-29-2008
nemo wrote:
> Hi,all.
> I'm on a toy ftp project and I want it to be convinient for the user
> to cancel an undergoing downloading while continue others. The
> following code explains:
> for file in download_files:
> self.ftp.retrbinary('RETR '+file, fileHandler)
> Thers seems not a solid way to cancel this transfer and I considered
> thread or process but I can't handle this correctly.
> Thread: I can't kill the thread in another thread, so...
> Process: There seems something wrong(raise an EOFError exception) when
> I use Process(target = download_fun, args = (dir,)) for each
> downloading after connection built.
> Some suggestions?


How about

for file in download_files:
try:
self.ftp.retrbinary('RETR %s' % file, fileHandler)
except KeyboardInterrupt:
print file, "transfer abandoned"

Then you can cancel a single file transfer with Ctrl/C.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

 
Reply With Quote
 
 
 
 
nemo
Guest
Posts: n/a
 
      12-29-2008
On Dec 29, 12:31*pm, Steve Holden <st...@holdenweb.com> wrote:
> nemo wrote:
> > Hi,all.
> > I'm on a toy ftp project and I want it to be convinient for the user
> > to cancel an undergoing downloading while continue others. The
> > following code explains:
> > for file in download_files:
> > * * self.ftp.retrbinary('RETR '+file, *fileHandler)
> > Thers seems not a solid way to cancel this transfer and I considered
> > thread or process but I can't handle this correctly.
> > Thread: I can't kill the thread in another thread, so...
> > Process: There seems something wrong(raise an EOFError exception) when
> > I use Process(target = download_fun, args = (dir,)) for each
> > downloading after connection built.
> > Some suggestions?

>
> How about
>
> for file in download_files:
> * * try:
> * * * * self.ftp.retrbinary('RETR %s' % file, fileHandler)
> * * except KeyboardInterrupt:
> * * * * print file, "transfer abandoned"
>
> Then you can cancel a single file transfer with Ctrl/C.
>
> regards
> *Steve
> --
> Steve Holden * * * *+1 571 484 6266 * +1 800 494 3119
> Holden Web LLC * * * * * * *http://www.holdenweb.com/


Thanks your advice,
actually, this ftp has a GUI interface, so I'm considering the
downloading part in another process or thread, whick is s a tricky
part for me to design.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sun.net.ftp.FtpProtocolException: Error reading FTP pending reply long990802@gmail.com Java 3 12-11-2005 02:46 AM
Re: ftplib question - ftp.dir() returns something and ftp.nlst()does not Nico Grubert Python 0 11-25-2005 10:09 AM
ftplib question - ftp.dir() returns something and ftp.nlst() does not Nico Grubert Python 0 11-24-2005 02:00 PM
Net::FTP problems getting files from Windows FTP server, but not Linux FTP Server. D. Buck Perl Misc 2 06-29-2004 02:05 PM
FTP over SSL vs FTP over SSH someone Java 1 04-25-2004 03:30 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57