I believe you may have encountered a known bug with a simple
solution. https://rt.cpan.org/Public/Bug/Display.html?id=53302
Now if only we could somehow get that patch released....
--
Rocco Caputo - rcap...@pobox.com
On Mar 9, 2010, at 03:10, p...@perlmeister.com wrote:
I'm trying to combine POE with a Gtk2 event loop, but it seems that
this
trips up POE, which then stops processing a wheel's output.
Below is a simplified example, which starts a Gtk2 loop and a Run
Wheel
which counts to 10000, but POE stops processing its output after 420
and
then hangs (freezes GUI).
Funny thing is, you can even throw out the Gtk GUI parts, and it still
fails, as long as the "use Gtk2 '-init'" line is there. As soon as
that's gone, POE processes everything correctly.
Would be great if someone could comment on if I'm doing something
weird.
-- Mike
Mike Schilli
p...@perlmeister.com
#!/usr/local/bin/perl -w
use strict;
use Gtk2 '-init';
use POE::Kernel { loop => "Glib" };
use POE::Session;
use POE::Wheel::Run;
use POE::Filter::Stream;
POE::Session->create(
inline_states => {
_start => \&ui_start,
play => \&play,
out => \&stdout_handler,
});
$poe_kernel->run();
exit 0;
###########################################
sub ui_start {
###########################################
my ($kernel, $session, $heap) = @_[KERNEL, SESSION, HEAP];
$heap->{main_window} = Gtk2::Window->new ('toplevel');
$kernel->yield('play');
}
###########################################
sub play {
###########################################
my ($kernel, $session, $heap) = @_[KERNEL, SESSION, HEAP];
my $wheel =
POE::Wheel::Run->new(
Program => sub { print "$_\n" for 1..10000; },
StdoutFilter => POE::Filter::Stream->new(),
StderrEvent => 'out',
StdoutEvent => 'out',
);
$heap->{player} = $wheel;
}
###########################################
sub stdout_handler {
###########################################
my ($heap, $input, $wheel_id) = @_[HEAP, ARG0, ARG1];
print STDERR "$input\n";
}