I'm trying to let a session stay in 'background' while another session is kept in progress in 'foreground'.
Here's a code snippet I wrote :
(this code is called from my main session, st_* have been defined to point to correct subs)
my $idling_task = POE::Wheel::Run->new(
Program => \&keep_idle_sess,
StdoutEvent => "st_out_idle",
StderrEvent => "st_err_idle",
CloseEvent => "st_cl_close",
) or die;
$_[HEAP]->{task}->{ $idling_task->ID } = $idling_task;sub st_out_idle {
my $stuff = $_[ARG0];
print "[st_out_idle] $stuff \n";
}sub st_err_idle {
my $stuff = $_[ARG0];
print "[st_err_idle] $stuff \n";
}sub st_cl_idle {
my $stuff = $_[ARG0];
print "[st_cl_idle] $stuff \n";
}sub keep_idle_sess {
POE::Session->new (
_start => \&keep_idle,
keep_hello => \&keep_hello,
) or die;
}sub keep_idle {
my $kernel = $_[KERNEL];
$kernel->yield("keep_hello");
}sub keep_hello {
my $kernel = $_[KERNEL];
print "hello !!\n";
$kernel->delay("keep_hello",20);
}My problem is that the delay method doesn't get started. Instead, I'm receiving a hello, then st_cl_idle confirmation that the child process did exit (I guess that's what I should have expected...).
What I want is to run that keep_hello sub looping itself outside my main poe session because it contains blocking operations freezing my main process for few seconds on every loop (the print hello is just an example). I was hoping creating a session from a Wheel::Run object would keep the session alive but I guess not :/
Can anyone help me ? Thanks
Laurent
