This Question has been edited to include code sample

In what I hope is my final question on POE... and thus giving me enough information to finish this mini-project I ask the following:

I have the following structure, and I apologize for no code sample at the moment. This is an extension to my questions: http://perlmonks.org/?node_id=708535 and

I have a POE::Component::JobQueue which I get information off passively. This works great, it goes into the new session and is able to Trigger a POE::Wheel::Run which runs an application that takes about 45 minutes to complete.

The Issue is:
As soon as the new Session with the Wheel::Run in it is fired, the session returns to the JobQueue saying it is finished. This isn't true, it should only be returning finished once the ChildClosed event is done in the Wheel::Run

As is normal, I have searched Google and the POE Cookbooks and still scratch my head.

POE::Component::JobQueue->spawn ( Alias => 'MyQueue', WorkerLimit => $numOfWorkerThreads, Worker => \&make_a_worker, Passive => { }, ); # Code that creates a seperate Session # Snipped due to Vendor limits sub handle_message { $kernel->yield( enqueue_msg => $msg ); } exit 0; # This gets posted to sub enqueue_msg { my ($kernel, $session, $message) = @_[ KERNEL, SESSION, ARG0 ]; print "-enqueue_job: -- Session: ", $session->ID, " message\n"; $kernel->post( MyQueue => 'enqueue', 'finish_job', $message ); } sub make_a_worker { my ( $postback, $message ) = @_; my @results = create_worker_session( $message ); $postback->(@results); } ## Do the actual creation of the worker session sub create_worker_session { my $message = shift; POE::Session->create( inline_states => { _start => \&worker_start, worker_child_stdout => \&worker_child_stdout, worker_closed => \&worker_closed, sig_child => \&sig_child, }, args => [ '', $message ], ); return "Message ID: ".$message->getHeaderField('MessageID')." -- F +inished... \n"; } sub worker_start { my ($kernel, $session, $heap, @args ) = @_[KERNEL, SESSION, HEAP, +ARG0 .. $#_]; $heap->{MessageID} = $args[1]->getHeaderField('MessageID'); $heap->{SessionID} = $session->ID; print " Message ID: ".$heap->{MessageID}; print " -start_message_process: ".$heap->{SessionID}."\n"; my $fullCMD = "/my/long/running/command -i foobar"; $heap->{cmdlinefish} = POE::Wheel::Run->new( Program => $fullCMD, StdoutEvent => "worker_child_stdout", CloseEvent => "worker_closed", StdioFilter => POE::Filter::Reference->new(), ); print " Message ID: ".$heap->{MessageID}; print " -start_message_process (end): ".$heap->{SessionID}."\n"; } sub worker_child_stdout { my ( $heap, $preargs ) = @_[ HEAP, ARG0 ]; print " Message ID: ".$heap->{MessageID}; print " -worker_child_stdout: $preargs\n"; } sub worker_closed { my ( $kernel, $heap, $preargs ) = @_[ KERNEL, HEAP, ARG1 ]; print " Message ID: ".$heap->{MessageID}; print " -worker_closed: $preargs\n"; $kernel->yield('sig_child'); } sub sig_child { my ( $heap, $sig, $pid, $exit_val ) = @_[ HEAP, ARG0, ARG1, ARG2 ] +; my $details = delete $heap->{cmdlinefish}; print " Message ID: ".$heap->{MessageID}; print " -sig_child\n"; return 0; }
Even smart people are dumb in most things...

In reply to POE, Sessons, POE::Wheel::Run and program flow by Devanchya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.