ftp design question
nemokingdom at gmail.com
Mon Dec 29 07:36:01 CET 2008
On Dec 29, 12:31 pm, Steve Holden <st... at 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:
> self.ftp.retrbinary('RETR %s' % file, fileHandler)
> except KeyboardInterrupt:
> print file, "transfer abandoned"
> Then you can cancel a single file transfer with Ctrl/C.
> 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.
More information about the Python-list