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

  • Home
  • SEARCH
  • 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 667645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:57:05+00:00 2026-05-13T23:57:05+00:00

I have a script that uses Parallel::ForkManager . However, the wait_all_children() process takes incredibly

  • 0

I have a script that uses Parallel::ForkManager. However, the wait_all_children() process takes incredibly long time even after all child-processes are completed. The way I know is by printing out some timestamps (see below). Does anyone have any idea what might be causing this (I have 16 CPU cores on my machine)?

my $pm = Parallel::ForkManager->new(16);
for my $i (1..16) {
    $pm->start($i) and next;

    ... do something within the child-process ...

    print (scalar localtime), " Process $i completed.\n";
    $pm->finish();
}
print (scalar localtime), " Waiting for some child process to finish.\n"; 
$pm->wait_all_children();
print (scalar localtime), " All processes finished.\n"; 

Clearly, I’ll get the Waiting for some child process to finish message first, with a timestamp of, say, 7:08:35. Then I’ll get a list of Process i completed messages, with the last one at 7:10:30. However, I do not receive the message All Processes finished until 7:16:33(!). Why is that 6-minute delay between 7:10:30 and 7:16:33? Thx!

  • 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-13T23:57:06+00:00Added an answer on May 13, 2026 at 11:57 pm

    I tried this:

    #!/opt/perl/bin/perl
    
    use strict; use warnings;
    
    use Parallel::ForkManager;
    
    my $pm = Parallel::ForkManager->new(16);
    
    for my $i (1..16) {
        $pm->start($i) and next;
        sleep rand 20;
        printf "%s : Process %d completed\n", scalar localtime, $i;
        $pm->finish;
    }
    
    printf "%s: Waiting for some child to finish\n", scalar localtime;
    $pm->wait_all_children;
    
    printf "%s: All processes finished.\n", scalar localtime; 
    

    I got:

    [sinan@archardy Src]$ ./y.pl
    Thu Mar 11 17:14:16 2010 : Process 3 completed
    Thu Mar 11 17:14:16 2010: Waiting for some child to finish
    Thu Mar 11 17:14:18 2010 : Process 8 completed
    Thu Mar 11 17:14:18 2010 : Process 14 completed
    <snip>...</snip>
    Thu Mar 11 17:14:34 2010 : Process 12 completed
    Thu Mar 11 17:14:34 2010: All processes finished.

    I have perl 5.10.1 on Linux with Parallel::ForkManager version 0.7.5.

    Therefore, I conclude that whatever issue you are having is happening as a consequence of what happens when you

    # ... do something within the child-process ...
    

    Update: The problem is, you are printing the Process finished message before the the finish call. Try the following version:

    #!/opt/perl/bin/perl
    
    use strict; use warnings;
    
    use Parallel::ForkManager;
    
    my $pm = Parallel::ForkManager->new(16);
    $pm->run_on_finish( sub {
        printf "%s : Process completed: @_\n", scalar localtime
    });
    
    for my $i (1..16) {
        $pm->start($i) and next;
        sleep rand 20;
        $pm->finish;
    }
    
    printf "%s: Waiting for some child to finish\n", scalar localtime;
    $pm->wait_all_children;
    
    printf "%s: All processes finished.\n", scalar localtime;
    

    See Callbacks in Parallel::ForkManager documentation for more information. If the delay disappears, then the symptom you are observing was due to the fact that you were claiming the forked process had finished before it was done.

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

Sidebar

Related Questions

I have an IronPython script that uses the TPL and Parallel.ForEach to process files
I have a simple PowerShell script that uses WMI to create a web site
I have an existing Perl script that uses the FTP object to send a
I have a script that takes a table name and generates a control file
I have a script that uses mcrypt_decrypt() function, but I get the following error
I have a script that uses the cmd Python module. The cmd module uses
I have a script that uses $(document).ready , but it doesn't use anything else
I have a script that uses PHP mail() function to send emails: mail(me@mydomain.com, Subject,
I have a script that uses a simple while loop to display a progress
I have a script that uses Tkinter to pop up a window with 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.