I have built a POE app which forks children, executes some work, returns status back up the parent. All works fine.
Currently this is all running from one Session. I now have a requirement to execute jobs which connect to the same modem bank together. I was thinking I might structure it in the following way:- PARENT - Create Session + POE::Wheel::Run (PWR) one process per all jobs which need to connect to modem bank CHILD 1 - Create Session + PWR one process per job CHILD n - Create Session + PWR one process per job This way I can use the heap of each session to manage the child jobs which are connected to each modem bank When using this mechanism to control how many jobs are passed to PWR its dependent on the heap content which in the original approach would contain all jobs :- while (keys(%{$heap->{task}}) < $PARALLELISM ) { Is there a better/simpler way someone can think of to use PWR and the Session Heap to continue to execute jobs against different devices whilst always maintaining 4 simultaneous jobs in each PWR (until complete) Simon Currently start and manage starting tasks this way:- sub StartTasks { =Head3 _start Function called when POE wants to start tasks Shouldnt start any more than $self->GetBSHParalleism($SDU::BatchSectionsHandler::SectionName) When it does it spawns children Event handlers allow information to be passed back to the parent process Mapping between state and function is done in the object states line in the POE::Session->create in _IterateChildrenParallel =cut my ($kernel, $self, $heap) = @_[KERNEL, OBJECT]; my ($child, $task); $self->{_logger}->debug("Enter/Reentry"); while (keys(%{$heap->{task}}) < $PARALLELISM ) { if (ref($self->{_children}) eq "ARRAY"){ $child = shift @{$self->{_children}}; last unless defined $child; $self->{_logger}->debug("ARRAY "."Child = $child"); $task = POE::Wheel::Run->new( Program => sub {local *__ANON__ = "_StartTasksProgramSub"; $self->_CreateChild($child); }, StdoutEvent => "TaskResult", StdoutFilter => POE::Filter::Reference->new(), StderrEvent => "TaskError", CloseEvent => "TaskDone", ); $heap->{task}->{$task->ID} = $task; $self->{_logger}->info("Created child Task/PID ".$task->ID."/".$task->PID); $_[KERNEL]->sig_child($task->PID, 'sig_child'); # Wheel events include the wheel's ID. $_[HEAP]{children_by_wid}{$task->ID} = $task; # Signal events include the process ID. $_[HEAP]{children_by_pid}{$task->PID} = $task; } elsif (ref($self->{_children}) eq "HASH") { $self->{_logger}->debug("HASH "."Child = $child"); $self->_CreateChild($child); } else { $self->{_logger}->debug("SCALAR "."Child = $child"); $self->_CreateChild($child); } # If end } # While end } Simon Taylor Development Team Lead NMS Applications Network Managed Services Nortel Networks (e) s...@nortel.com (p) +44 1279 402291 ESN 6 742 2291 (m) +44 7740 533743 ESN 6 748 3743 (yim) setuk_nortel