Process with ftplib

Discussion in 'Python' started by nemo, Dec 26, 2008.

  1. nemo

    nemo Guest

    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?
    nemo, Dec 26, 2008
    #1
    1. Advertising

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

    --
    Gabriel Genellina
    Gabriel Genellina, Dec 26, 2008
    #2
    1. Advertising

  3. nemo

    nemo Guest

    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
    nemo, Dec 27, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    726
    Steve Holden
    Sep 12, 2003
  2. Gerrit Holl
    Replies:
    0
    Views:
    889
    Gerrit Holl
    Dec 29, 2003
  3. Michael_Goettsche

    Uploading a file with ftplib

    Michael_Goettsche, Jan 1, 2004, in forum: Python
    Replies:
    2
    Views:
    346
    Michael_Goettsche
    Jan 1, 2004
  4. Stephen Horne
    Replies:
    2
    Views:
    371
    Stephen Horne
    Feb 22, 2004
  5. Joshua Burvill

    Sending file to print server using ftplib

    Joshua Burvill, May 20, 2004, in forum: Python
    Replies:
    0
    Views:
    317
    Joshua Burvill
    May 20, 2004
Loading...

Share This Page