Process with ftplib

N

nemo

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?
 
G

Gabriel Genellina

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-multiprocessing/index.html
 
N

nemo

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...

thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top