Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: POE, Sessons, POE::Wheel::Run and program flow

by themage (Friar)
on Sep 04, 2008 at 17:22 UTC ( #709071=note: print w/ replies, xml ) Need Help??


in reply to POE, Sessons, POE::Wheel::Run and program flow

sub make_a_worker { my ( $postback, $message ) = @_; POE::Session->create( inline_states => { _start => \&worker_start, worker_child_stdout => \&worker_child_stdout, worker_closed => \&worker_closed, sig_child => \&sig_child, }, args => [ @_ ], ); } sub worker_start { my ($kernel, $session, $heap, @args ) = @_[KERNEL, SESSION, HEAP, +ARG0 .. $#_]; $heap->{postback}=$args[0]; $heap->{message}=$args[1]; $heap->{MessageID} = $args[1]->getHeaderField('MessageID'); $heap->{SessionID} = $session->ID; # ... your code as is... print " Message ID: ".$heap->{MessageID}; print " -start_message_process (end): ".$heap->{SessionID}."\n"; } # .... sub worker_closed { my ( $kernel, $heap) = @_[ KERNEL, HEAP]; my $postback=$heap->{postback}; my @results=@{$heap->{results}}; # I don't know how $heap->{results} is created, but I presume it i +s based somehow on the output of your process $postback->(@results); # ... anything you need (yield('sig_child') is not one of that) }


This should do it.

Your problems, create a session (and that include almost any type of component don't ways for the session to end, one create it and add it to the sessions poll, so when you call your callback after create the session you are signaling the JobQueue that the job is done.


Comment on Re: POE, Sessons, POE::Wheel::Run and program flow
Download Code
Re^2: POE, Sessons, POE::Wheel::Run and program flow
by Devanchya (Beadle) on Sep 04, 2008 at 17:59 UTC
    That did it! Thanks.
    Even smart people are dumb in most things...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://709071]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2014-12-22 11:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (116 votes), past polls