On Sat, Jan 25, 2003 at 01:45:38PM -0800, Stephen Nelson wrote:
> Hello all...
>
> I'm working on a POE project that uses POE::Wheel::Run to start external
> programs at specified times. (Background: it's going to be broadcasting
> TV programs.) My test code passes all tests, but once I've run all my
> tests, the POE::Kernel::run method keeps on running, and doesn't return.
Neat! I hope POE won't be responsible for any test patterns or
"Please stand by..." cards. :)
> Obviously, I'm failing to clean something up, so the POE kernel thinks
> I'm not finished with all my event processing, but I can't figure out
> what. I'm hoping that sharper eyes and minds here can spot what I've
> missed.
[...]
> Here's the code:
Thank you for the test case. I was able to reproduce and track down
the problem quickly.
Your hunch is absolutely correct: something wasn't cleaned up
properly. In sub play, you create a POE::Wheel::Run instance and save
it in $_[OBJECT]->{run}.
> $self->{'run'} = POE::Wheel::Run->new(
> Program => [ '/bin/sleep', $play_args->[0] ],
> StderrEvent => 'nullevent',
> );
But in content_ended() you remove $_[HEAP]->{run}. That's not where
the Wheel::Run instance is, so it never destructs, and the content
handler doesn't go away.
> delete $heap->{'run'};
Also, your wait() call in content_ended() isn't necessary.
POE::Kernel reaps child processes for you, and it sends your their
PIDs and exit values as ARG1 and ARG2, respectively.
-- Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/