Loading ...
Sorry, an error occurred while loading the content.

Parallel::ForkManager question

Expand Messages
  • Noah Garrett Wallach
    Hi there, okay I have a Parallel::ForkManager question. I am just starting off using it. I am getting errors and not sure completely how to mitigate them. I
    Message 1 of 2 , Apr 11, 2011
    • 0 Attachment
      Hi there,


      okay I have a Parallel::ForkManager question. I am just starting off
      using it. I am getting errors and not sure completely how to mitigate
      them. I guess there is an exception problem that is going on.



      here is the code:

      --- snip ----
      $pm = new Parallel::ForkManager( $maxjobs );
      $pm->run_on_finish( );

      for $device (sort @devices) {
      next if ( exists $errors{$device} );
      my $pid = $pm->start($device) and next;
      my $id = check_device($device, $logfile);
      sleep 1;
      $pm->finish;
      }
      $pm->wait_all_children;

      --- snip ---


      here are the errors that crop up twice.

      --- snip ----

      Exiting subroutine via next at ./blah.pl line 215 (#2)
      (W exiting) You are exiting a subroutine by unconventional means, such
      as a goto, or a loop control statement.

      Uncaught exception from user code:
      Cannot start another process while you are in the child process
      at /home/y/lib/perl5/site_perl/5.8/Parallel/ForkManager.pm line 281.
      at /home/y/lib/perl5/site_perl/5.8/Parallel/ForkManager.pm line 281

      Parallel::ForkManager::start('Parallel::ForkManager=HASH(0x1271a34)',
      'blah') called at ./chassis.alarms.pl line 178

      --- snip ---


      Cheers,

      Noah
    • Tim Lewis
      I am just wondering if it is getting confused by the next statement. Can you try this code below with a foreach and see if it works with that? Tim foreach
      Message 2 of 2 , Apr 12, 2011
      • 0 Attachment
        I am just wondering if it is getting confused by the "next" statement. Can you try this code below with a foreach and see if it works with that?

        Tim

        foreach my $device (sort @devices) {
        if (!( exists $errors{$device} )) { # if not an error
        my $pid = $pm->start($device) and next;
        my $id = check_device($device, $logfile);
        sleep 1;
        $pm->finish;
        }
        }
        $pm->wait_all_children;

        ---- Noah Garrett Wallach <noah-list@...> wrote:
        > Hi there,
        >
        >
        > okay I have a Parallel::ForkManager question. I am just starting off
        > using it. I am getting errors and not sure completely how to mitigate
        > them. I guess there is an exception problem that is going on.
        >
        >
        >
        > here is the code:
        >
        > --- snip ----
        > $pm = new Parallel::ForkManager( $maxjobs );
        > $pm->run_on_finish( );
        >
        > for $device (sort @devices) {
        > next if ( exists $errors{$device} );
        > my $pid = $pm->start($device) and next;
        > my $id = check_device($device, $logfile);
        > sleep 1;
        > $pm->finish;
        > }
        > $pm->wait_all_children;
        >
        > --- snip ---
        >
        >
        > here are the errors that crop up twice.
        >
        > --- snip ----
        >
        > Exiting subroutine via next at ./blah.pl line 215 (#2)
        > (W exiting) You are exiting a subroutine by unconventional means, such
        > as a goto, or a loop control statement.
        >
        > Uncaught exception from user code:
        > Cannot start another process while you are in the child process
        > at /home/y/lib/perl5/site_perl/5.8/Parallel/ForkManager.pm line 281.
        > at /home/y/lib/perl5/site_perl/5.8/Parallel/ForkManager.pm line 281
        >
        > Parallel::ForkManager::start('Parallel::ForkManager=HASH(0x1271a34)',
        > 'blah') called at ./chassis.alarms.pl line 178
        >
        > --- snip ---
        >
        >
        > Cheers,
        >
        > Noah
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.