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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.