Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8226493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:47:21+00:00 2026-06-07T15:47:21+00:00

I am using Python’s multiprocessing to do bulk downloads using FTP. However, when I

  • 0

I am using Python’s multiprocessing to do bulk downloads using FTP. However, when I try to open more than 5 ftp sessions, an EOFError is raised, meaning the host is disconnecting me for opening too many sessions.

The only solution I see is to open a single FTP object and pass it to the necessary methods. The problem is that because multiprocessing uses pickling to move objects around, and FTP objects can’t be pickled, this is not possible. My question is thus whether it is possible to work around this by finding a way to pickle FTP objects?

My code is of the following form:

def get_file(name):
    #code here    

def worker(name_list, out_q):
    lst = []
    for name in name_list:
        lst.append(get_file(name))
    out_q.put(lst)

if __name__ == '__main__':

    #est ftp cnxn
    ftp = FTP('ftp.blah.blah', 'anonymous', 'meow')

    #multiprocessing code here

The get_file def needs access to the ftp connection, and if I put it outside of the if __name__ == '__main__' block, then a new ftp connection is created each time a process runs through the code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:47:22+00:00Added an answer on June 7, 2026 at 3:47 pm

    I don’t really understand why you would want to do that:

    • create a bunch of processes to download stuff in parallel
    • but only use one FTP object, in effect serializing the download

    How exactly does this solve your problem?

    But, instead of serializing the FTP object, create a process for FTP requests and devise a mini-language for communicating with that process – let your other processes send (easily pickleable) messsages of the form get src dst.

    EDIT: Just checked the documentation for [ftplib][1]. Nowhere does it say it can handle multiple calls. Assume it doesn’t!

    So, I would do this:

    • create MAX_CONNECTIONS (e.g. 5) FTP worker processes that
    • contact a master process that has a queue of files to retrieve
    • worker processes retrieve an task from the queue, downloads the file and checks master for new stuff to do
    • repeat until the work is done
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Python I am trying to analyze a tab delimited file. I open the
[Using Python 3.2] If I don't provide encoding argument to open , the file
Using Python's csv module, is it possible to read an entire, large, csv file
Using Python how do you reduce a list of lists by an ordered subset
Using Python, I want to know whether Java is installed.
Using Python module re, how to get the equivalent of the \w (which matches
Using Python, how does one parse/access files with Linux-specific features, like ~/.mozilla/firefox/*.default ? I've
Using Python I would like to find the date object for last Wednesday. I
Using Python I want to randomly rearrange sections of a string based on a
Using Python I need to insert a newline character into a string every 64

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.