cmv has asked for the wisdom of the Perl Monks concerning the following question:
Helpful Monks-
I wish to use POE::Wheel::Run along with Tk to do some things.
As a starting point, I always like to grab the example code from the CPAN docs and start hacking on that.
The unmodified CPAN code runs fine as is on my various unix platforms. To get it to run under Activestate perl, I simply changed the Program line to be:
Program => 'dir',
and it also works fine.
The next step was to try to install the use Tk; at the beginning, so that POE could try to configure itself for the Tk event loop. Simply adding use Tk; before use POE; caused the program to fail on Activestate Perl (again it works fine on unix platforms).
Having a small bit of experience with these problems, I also tried use POE qw (Loop::TkActiveState); with no luck either. In addition, I did notice a POE::Wheel::Run::Win32, which I installed from Activestate and tried, but it failed even worse.
The script fails, by briefly flashing a blank Tk window, then exiting. The only output I see is the line "Child pid -2564 started as wheel 1."
Any help or pointers is appreciated!
Thanks
-Craig
PS - I'm attaching the code that I'm using in the following readmore tags, for completeness.
use warnings; use strict; use Tk; # Fails under Activestate, when this is uncommented #use POE qw( Loop::TkActiveState ); use POE; use POE::Wheel::Run; POE::Session->create( inline_states => { _start => \&on_start, got_child_stdout => \&on_child_stdout, got_child_stderr => \&on_child_stderr, got_child_close => \&on_child_close, got_child_signal => \&on_child_signal, } ); POE::Kernel->run(); exit 0; sub on_start { my $child = POE::Wheel::Run->new( Program => 'dir', StdoutEvent => "got_child_stdout", StderrEvent => "got_child_stderr", CloseEvent => "got_child_close", ); $_[KERNEL]->sig_child($child->PID, "got_child_signal"); # Wheel events include the wheel's ID. $_[HEAP]{children_by_wid}{$child->ID} = $child; # Signal events include the process ID. $_[HEAP]{children_by_pid}{$child->PID} = $child; print( "Child pid ", $child->PID, " started as wheel ", $child->ID, ".\n" ); } # Wheel event, including the wheel's ID. sub on_child_stdout { my ($stdout_line, $wheel_id) = @_[ARG0, ARG1]; my $child = $_[HEAP]{children_by_wid}{$wheel_id}; print "pid ", $child->PID, " STDOUT: $stdout_line\n"; } # Wheel event, including the wheel's ID. sub on_child_stderr { my ($stderr_line, $wheel_id) = @_[ARG0, ARG1]; my $child = $_[HEAP]{children_by_wid}{$wheel_id}; print "pid ", $child->PID, " STDERR: $stderr_line\n"; } # Wheel event, including the wheel's ID. sub on_child_close { my $wheel_id = $_[ARG0]; my $child = delete $_[HEAP]{children_by_wid}{$wheel_id}; # May have been reaped by on_child_signal(). unless (defined $child) { print "wid $wheel_id closed all pipes.\n"; return; } print "pid ", $child->PID, " closed all pipes.\n"; delete $_[HEAP]{children_by_pid}{$child->PID}; } sub on_child_signal { print "pid $_[ARG1] exited with status $_[ARG2].\n"; my $child = delete $_[HEAP]{children_by_pid}{$_[ARG1]}; # May have been reaped by on_child_close(). return unless defined $child; delete $_[HEAP]{children_by_wid}{$child->ID}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: POE::Wheel::Run & Tk Problems
by Anonymous Monk on Aug 05, 2009 at 01:01 UTC | |
|
Re: POE::Wheel::Run & Tk Problems
by rcaputo (Chaplain) on Aug 05, 2009 at 04:22 UTC | |
by Khen1950fx (Canon) on Aug 05, 2009 at 06:25 UTC | |
by rcaputo (Chaplain) on Aug 05, 2009 at 06:49 UTC | |
by Anonymous Monk on Aug 05, 2009 at 06:30 UTC | |
by Khen1950fx (Canon) on Aug 05, 2009 at 06:35 UTC | |
by Anonymous Monk on Aug 05, 2009 at 07:07 UTC | |
by cmv (Chaplain) on Aug 05, 2009 at 13:42 UTC |