in reply to Parallel::Forkmanager question
What platform are you on, and what are you expecting/getting in $rc?
How are you confirming that the procs aren't fed out properly and finishing in an order that you don't expect?
How many forks are you starting with your init call? Please show the code that shows how you're initializing Parallel::ForkManager.
In other words, what output are you expecting, and what output are you receiving that doesn't align with expectations?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parallel::Forkmanager question
by jamesgerard1964 (Novice) on Apr 06, 2017 at 13:20 UTC | |
platform is Linux Red Hat. I am currently testing with 9 servers in the list. When I run the script without Parallel::Forkmanager what is happening is that the script will loop thru and process each server using the system call to scp a file. The script will wait for that system call to finish and then continue to the next server. It seems like that is exactly whats happening with the fork. It's processing 1 server at a time, unless I'm not seeing this correctly. The reason I had the wait for all children is that I want to make sure all the servers have been processed before continuing on. I am adding time stamps to the print statements to show what is happening. Here is the code and the output.
04/06/2017 08:56:23 127266: child process started, with a key of server01 (127269)
| [reply] [d/l] |
by 1nickt (Canon) on Apr 06, 2017 at 13:49 UTC | |
As your output shows, the same process is handling all the tasks. That's because the parent is forking a child but then continuing the work itself. You are missing the statement that causes the parent to skip out of the loop. See the doc for Parallel::ForkManager, which states (emphasis added): The following example shows the difference: Output:
Hope this helps!
The way forward always starts with a minimal test.
| [reply] [d/l] [select] |
by jamesgerard1964 (Novice) on Apr 06, 2017 at 21:28 UTC | |
I changed the code to include the 'start and next' and moved the finish within the if pid loop. However now I'm getting completely new error messages.
| [reply] |
by jamesgerard1964 (Novice) on Apr 06, 2017 at 21:43 UTC | |
sorry, posted too soon. I had to take out the if pid and now its works great. Thanks for the help. | [reply] |