Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Process with ftplib (http://www.velocityreviews.com/forums/t650117-process-with-ftplib.html)

nemo 12-26-2008 01:07 PM

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?

Gabriel Genellina 12-26-2008 02:40 PM

Re: Process with ftplib
 
En Fri, 26 Dec 2008 11:07:30 -0200, nemo <nemokingdom@gmail.com> 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...ing/index.html

--
Gabriel Genellina


nemo 12-27-2008 01:29 AM

Re: Process with ftplib
 
On Dec 26, 10:40*pm, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
wrote:
> En Fri, 26 Dec 2008 11:07:30 -0200, nemo <nemoking...@gmail.com> 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...t-2007-10-mult...
>
> --
> Gabriel Genellina


thanks.

--
nemo


All times are GMT. The time now is 09:49 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.