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 7724803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:46:48+00:00 2026-06-01T04:46:48+00:00

I have a downloader function that downloads multiple files parallely. I use multiprocessing.Pool.map_async in

  • 0

I have a downloader function that downloads multiple files parallely.
I use multiprocessing.Pool.map_async in order to download different chunks of the same file.
I would like to show a statusbar of the download. For this, I need to know the total bytes that has been already downloaded (total_bytes_dl).

    pool = multiprocessing.Pool(processes)
    mapObj = pool.map_async(f, args)

    while not mapObj.ready():
        status = r"%.2f MB / %.2f MB" % (total_bytes_dl / 1024.0 / 1024.0, filesize / 1024.0 / 1024.0,)
        status = status + chr(8)*(len(status)+1)
        print status,
        time.sleep(0.5)

Is there a way to set a variable that will be shared among all these processes AND the main process, so every process can append the amount of bytes that has just downloaded?

  • 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-01T04:46:50+00:00Added an answer on June 1, 2026 at 4:46 am

    The solution was to intilize the new process and pass the shared ctypes value:

    from ctypes import c_int
    import dummy
    
    shared_bytes_var = multiprocessing.Value(c_int)
    
    def Func(...):
        ....
        pool = multiprocessing.Pool(initializer=_initProcess,initargs=(shared_bytes_var,))
        ....
    
    def _initProcess(x):
      dummy.shared_bytes_var = x
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that downloads a video using AsyncTask. //DOWNLOAD VIDEOS private
I have written an iOS app that calls NSUrlConnection multiple times to download image
I use Visual Studio 2008 Professional automated tests. I have a function that writes
I have a controller that in nutshell is as follows: public function download($id) {
I have a method in my controller public function download($filepath){ $download_path = $_SERVER['DOCUMENT_ROOT']. mediabox/import;
To use the APK Downloader( link ),i have to know the nook's device id.
I'm writing a simple batch downloader for files, which have the format Y-m-d.pdf. I
I have a contact manager program that I'd like to design for multiple network
I have an array that stores a few urls of XML files that need
Hey everyone, I have written a script that downloads a zip file from a

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.