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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:47:06+00:00 2026-05-28T20:47:06+00:00

Background: I haven’t had much experience with multi-process Perl scripts. I have a data

  • 0

Background:
I haven’t had much experience with multi-process Perl scripts. I have a data cleanup process for the FooService that is taking over 12 hours to complete, and when I investigated, I found that almost all of that time was spent waiting for the FooClient to return me data. I was looking into a multi-process way to do the task, and a coworker recommended Parallel::Fork::BossWorkerAsync over the simple fork() I was doing before. I liked it since it lowered my memory use by a ton.

Problem:
BossWorkerAsync looks pretty neat, the perldoc is great, and running it in no-write test mode works really well, pushing my execution time under an hour. My only problem is that the documentation doesn’t really explain how shared data works with the “init_handler => &x” construction setting. I want each worker to have its own FooClient, just to avoid any sort of synchronization issues. I went with what I thought was correct, but I’m sort of paranoid about it, and also want to make sure that I’m dealing with this in the most correct way.

Code:

# The number of children to spawn, modify after performance testing
Readonly my $CHILDREN => 40;

# Each child will set their own client
my $client;

my $bw = Parallel::Fork::BossWorkerAsync->new(
    work_handler => \&process_keys,
    init_handler => \&setup_client,
    worker_count => $CHILDREN,
);

send_work($bw);

while ($bw->pending()) {
    my $ref = $bw->get_result();
    # Do stuff with the result
}

$bw->shut_down();
exit;

sub setup_client {
    $client = FooClient->new();
}

Am I handling the $client that I don’t want shared correctly? I kept the same sort of deal I had with my fork() version, where I set the $client after the fork(), but I’m just worried that it’s not the right way to do this.

  • 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-28T20:47:07+00:00Added an answer on May 28, 2026 at 8:47 pm

    Yes, you’re using the module, and the init_handler, correctly. The handler is called just after the fork, in each child, before it enters the blocking select loop, waiting for a job.

    I’m the author of the module. I’m sorry it took me so long to notice this, and respond. Glad to see the code is being used.

    Cheers,
    -joe

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

Sidebar

Related Questions

I have a background script that is responsible for getting and setting data to
Background: I have a kubuntu laptop right now that I can't use wirelessly, i.e.
Background: we have an application that generates reports from HTML (that may or may
I haven't done much python - coming from a C/Java background - so excuse
I have a table in a report and a textbox that changes its background
I haven't been able to find anything that can colour the background and/or add
So I come from a C background (originally originally, though I haven't used that
Background I have a Crystal Reports 2008 file that came my way from a
Background: I have a little video playing app with a UI inspired by the
Background I have a massive db for a SharePoint site collection. It is 130GB

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.