Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: While loop not exiting when expected.

by broquaint (Abbot)
on Jun 25, 2004 at 10:16 UTC ( #369587=note: print w/replies, xml ) Need Help??


in reply to While loop not exiting when expected.

I can't see the problem presently, but this does seem like a pretty ideal solution for Parallel::ForkManager
use Parallel::ForkManager; open my $fh, '<', 'foo.csv' or die "ack: $!"; my $pm = Parallel::ForkManager->new( MAX_KIDS ); while(<$fh>) { my $pid = $pm->start and next; { your_sub( split ',' ); } $pm->end; }
HTH

_________
broquaint

update: s/Parra/Para/g, thanks to liz and Albannach for picking up on that one

Replies are listed 'Best First'.
Re^2: While loop not exiting when expected.
by BazB (Priest) on Jun 25, 2004 at 10:22 UTC

    broquaint, thanks.
    I am aware of Parallel::ForkManager, but I figured it wasn't worth the grief of installing an extra module for a relatively small amount of code.

    Of course, that was before I realised my code wasn't playing nice...

    Update: I've tried broquaint's suggestion of Parallel::ForkManager, and that suffers from the same problem on Solaris (5.6.1 and 5.8.4), but is fine on Linux.

    Update 2: I tried another tactic - don't read the configuration file and fork children in a single loop.
    Instead, I open and read the configuration file and store the information in an array, then iterate over the array using foreach, kicking off children and reaping as before.
    This approach does work correctly, but still doesn't reveal why the original code fails.


    If the information in this post is inaccurate, or just plain wrong, don't just downvote - please post explaining what's wrong.
    That way everyone learns.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://369587]
help
Chatterbox?
[LanX]: ... so my boss started a project with the newest sun servers and invited the traders to come on weekend to test it... and they were so pleased, that they forced him to keep it in production...
[ambrus]: Corion: sure, this is the long-term plan. The short term is that I have to run this ungodly mess to get results from the new input data today.
[Corion]: ambrus: Most of our "automation" is tied to process exit codes and a shell pipeline :-\
[LanX]: ... a week later they realized that one of the databases - which recorded how much the other banks due to this bank - was not correctly plugged
[ambrus]: Corion: I have no problem with exit codes and shell pipeline. My problem is that the current process requires a lot of manual intervention from me, including editing the source codes.
[ambrus]: (Also a lot of manual intervention by two or three other co-workers, who do other parts of the process.)
[ambrus]: Some of the manual part is unavoidable, but not all.
[choroba]: LanX was there a way to recover the numbers from the remaining information?
[Corion]: LanX: Ow ;)

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (12)
As of 2017-03-29 11:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (350 votes). Check out past polls.