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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:14:31+00:00 2026-05-25T18:14:31+00:00

I have a script that parses a file containing directories to other file, that

  • 0

I have a script that parses a file containing directories to other file, that have to be opened and read searching for a keyword.
Since the number of file is growing I’d like to enable multiprocessing to reduce the amount of time requested to complete the job.

I was thinking to leave the parent process parsing the file containing directories and use child processes to fetch the other files. Since the parent would need to obtain the data before to create childs it would be a blocking architecture (the parent has to read all the file before to call childs), while I’d like to send to one of the childs the list containing directories each 100 results.

So, the parent continues parsing the file while childs work at the same time to find the keyword.

How could I do something like that?
If you need more explanations, please, ask me and I’ll tell you more.

Thanks.

  • 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-05-25T18:14:32+00:00Added an answer on May 25, 2026 at 6:14 pm

    I was thinking to leave the parent process parsing the file containing directories and use child processes to fetch the other files.

    A directory is a name. The parent parses a list and provides the directory name to each child. Right? The child then reads the files inside the directory.

    Since the parent would need to obtain the data before to create childs it would be a blocking architecture (the parent has to read all the file before to call childs),

    Um. The child doesn’t read the files inside the directory? Up above, it says the child does read the files. It’s silly for the parent to read a lot of data and push that to the children.

    while I’d like to send to one of the childs the list containing directories each 100 results.

    Well. This is different. Now you want to have the parent read a directory name, read a batch of 100 file names and send the file names to the child. Okay. That’s less silly than reading all the data. Now it’s just 100 names.

    So, the parent continues parsing the file while childs work at the same time to find the keyword.

    Okay. But you’re totally missing the opportunity for parallel processing.

    Read the multprocessing module carefully.

    What you want are two queues and two kinds of workers.

    Your application will build the two queues. It will build a source Process, a pool of “get batch” worker processes, and a pool of “get files” worker processes.

    • Source. This process is (basically) a function that reads the original “file containing directories”. And puts each directory name into the “get batch” queue.

    • Get Batch. This is a pool of processes. Each process is a function that gets an entry from the “get batch” queue. This is a directory name. It then reads the directory and enqueues a tuple of 100 file names into the “get files” queue.

    • Get Files. This is a pool of processes. Each process is a function that gets an entry from the “get files” queue. This is a tuple of 100 files. It then opens and reads these 100 files doing god-knows-what with them.

    The idea of the multiprocessing module is to use pools of workers that all get their tasks from a queue and put their results into another queue. These workers all run at the same time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On a webserver, I have a php script that parses a .sql file (which
I have a python script that parses an XML file that contains part information
I have a script that takes an uploaded text file, parses it and then
I have a jQuery search script that queries a PHP file then parses the
I have developed a C# script that opens an XLS file, parses it and
I have a script that parses xml file to generate SQLite table automatically. And,
I have a script that parses the filenames of TV episodes (show.name.s01e02.avi for example),
I currently have a Perl CGI script that parses incoming XML requests using XML::Simple
I have a script that takes a table name and generates a control file
I have a php script that parses XML files and creates a large SQL

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.