Process with ftplib
Hi,all There seems something wrong when I use multiprocessing.Process with ftplib, My ftp class has a connection method like this: class qftp: def __init__(...): self.ftp = FTP() def connection(self): self.ftp.connect(self.addr, self.port) self.ftp.login(self.user, self.password) when i call the method like: ftp = qftp(host, port, user, password) ftp.connect() ftp.pwd() It works well but when I using the Process module, something seems wrong: ftp = qftp(host, port, user, password) p = multiprocessing.Process(target = ftp.connect) p.join() ftp.ftp.pwd() #after join, i think a connection has made, but it throws an exception This give me a 'NoneType object has no attribute sendall' exception. I wondered why? -- http://mail.python.org/mailman/listinfo/python-list
Re: Process with ftplib
On Dec 26, 10:40 pm, "Gabriel Genellina" wrote: > En Fri, 26 Dec 2008 11:07:30 -0200, nemo escribió: > > > There seems something wrong when I use multiprocessing.Process with > > ftplib, [...] > > It works well but when I using the Process module, something seems > > wrong: > > ftp = qftp(host, port, user, password) > > p = multiprocessing.Process(target = ftp.connect) > > p.join() > > ftp.ftp.pwd() #after join, i think a connection has > > made, but it throws an exception > > This give me a 'NoneType object has no attribute sendall' exception. I > > wondered why? > > After p.join(), the second process has finished. The global variable ftp > isn't shared between them - so it does not reflect the changes made in the > other process. > > An introductory article to > multiprocessing:http://www.doughellmann.com/articles/CompletelyDifferent-2007-10-mult... > > -- > Gabriel Genellina thanks. -- nemo -- http://mail.python.org/mailman/listinfo/python-list
ftp EOF error, thread and process
Hi all, My code like this raise an EOFError, It happens if I use the Process module, while, if I use thread.start_new_thread(ftp.pwd,()), it seems works well. And I wondered why. from ftplib import FTP import thread from multiprocessing import Process if __name__ == '__main__': ftp = FTP('localhost', 'movie', 'movie') print ftp.pwd() p = Process(target = ftp.pwd) # thread.start_new_thread (ftp.pwd,()), p.start() p.join() -- http://mail.python.org/mailman/listinfo/python-list
ftp design question
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? -- http://mail.python.org/mailman/listinfo/python-list
Re: ftp design question
On Dec 29, 12:31 pm, Steve Holden 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. -- http://mail.python.org/mailman/listinfo/python-list