Re: new to POE
On Mon, Jun 23, 2003 at 05:01:59PM -0400, Carlton Lo wrote: > I've tried one of the example in the cookbook : Child Processes 3 and I get this > error (yes I'm using Windows 2000) > > C:\Work\Clients\Comcast\RMEMigrate\perl>poe.pl > MSWin32 does not fully support fork+exec > BEGIN failed--compilation aborted at C:/tools/Perl/lib/POE/Wheel/Run.pm line 63. > > Compilation failed in require at (eval 30) line 1. > BEGIN failed--compilation aborted at (eval 30) line 1. > could not import qw(Wheel::Run) at C:\Work\Clients\Comcast\RMEMigrate\perl\poe.p > l line 11 > BEGIN failed--compilation aborted at C:\Work\Clients\Comcast\RMEMigrate\perl\poe > .pl line 11. I haven't been able to get fork() and exec() to work reliably under ActivePerl for Win32. As a result, POE::Wheel::Run (which currently uses fork and exec) is not supported on that platform. If someone with more Win32-fu can get this working, I'll be happy to make it officially supported in 0.27. -- Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/
Re: new to POE
>From what I've read fork() is flaky inWin32 due to not having a fork() system command. It would seem that POE has taken notice of this, and wishes not to continue. I'm sure if you check http://www.perlmonks.org , and http://www.google.com, you will find a useful alternative to fork()ing in Win32. - Original Message - From: "Carlton Lo" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, June 23, 2003 5:01 PM Subject: new to POE I've tried one of the example in the cookbook : Child Processes 3 and I get this error (yes I'm using Windows 2000) C:\Work\Clients\Comcast\RMEMigrate\perl>poe.pl MSWin32 does not fully support fork+exec BEGIN failed--compilation aborted at C:/tools/Perl/lib/POE/Wheel/Run.pm line 63. Compilation failed in require at (eval 30) line 1. BEGIN failed--compilation aborted at (eval 30) line 1. could not import qw(Wheel::Run) at C:\Work\Clients\Comcast\RMEMigrate\perl\poe.p l line 11 BEGIN failed--compilation aborted at C:\Work\Clients\Comcast\RMEMigrate\perl\poe .pl line 11. Carlton Lo Pluris 550 Cochituate Road Framingham, MA 01701 Tel: (508) 663-1089 Fax: (508) 663-1060 mailto:[EMAIL PROTECTED]
new to POE
I've tried one of the example in the cookbook : Child Processes 3 and I get this error (yes I'm using Windows 2000) C:\Work\Clients\Comcast\RMEMigrate\perl>poe.pl MSWin32 does not fully support fork+exec BEGIN failed--compilation aborted at C:/tools/Perl/lib/POE/Wheel/Run.pm line 63. Compilation failed in require at (eval 30) line 1. BEGIN failed--compilation aborted at (eval 30) line 1. could not import qw(Wheel::Run) at C:\Work\Clients\Comcast\RMEMigrate\perl\poe.p l line 11 BEGIN failed--compilation aborted at C:\Work\Clients\Comcast\RMEMigrate\perl\poe .pl line 11. Carlton Lo Pluris 550 Cochituate Road Framingham, MA 01701 Tel: (508) 663-1089 Fax: (508) 663-1060 mailto:[EMAIL PROTECTED]
RE: problems using package methods...
that was it. mad I didn't see it, but thanks! -Original Message- From: Dan McCormick [mailto:[EMAIL PROTECTED] Sent: Monday, June 23, 2003 8:45 AM To: Josh; [EMAIL PROTECTED] Subject: Re: problems using package methods... Hi Josh, If Ping.pm is a separate file, you need to "use POE" to import the KERNEL, HEAP, etc. constants. Try that and see if things improve. Dan Josh wrote: > > I am having a strange problem w/package methods not seeming to work > properly, at least as far as I understand them. This is my first POE > program, it is a simple program that pings some hosts using > POE::Component::Client::Ping. I am trying to put the event handlers related > to pinging in their own package. If anyone has any ideas or suggestions I > would really appreciate it, bc I have read all the docs and online resource > and this is erally starting to bake my noodle. Example output and the code > is below. > > -josh > > I first wrote the program using inline handlers w/all the coderefs in the > same file. running this works fine: > > # perl daemon.pl > START KERNEL > 216.33.69.110 0.0165859460830688 > 216.33.68.131 0.0180959701538086 > 216.33.69.33 0.0192290544509888 > 216.33.68.132 0.0205649137496948 > 216.33.66.190 0.0219370126724243 > 216.33.66.150 0.0233149528503418 > 64.37.201.22 0.0246679782867432 > 216.33.69.110 : NO RESPONSE > 216.33.68.131 : NO RESPONSE > 216.33.69.33 : NO RESPONSE > 216.33.68.132 : NO RESPONSE > 216.33.66.190 : NO RESPONSE > 216.33.66.150 : NO RESPONSE > 64.37.201.22 : NO RESPONSE > STOP sess 3 > STOP KERNEL > > However, if I move the handlers out of this file to a package and change the > Session's event mapping to use package methods, none of my handlers get > invoked (w/assertions and debuggin this time): > > START KERNEL > POE::Kernel is polling for signals at 1056131081.00576 at > /usr/local/lib/perl5/site_perl/5.8.0/POE/Kernel.pm line 2711. > POE::Kernel has no child processes at > /usr/local/lib/perl5/site_perl/5.8.0/POE/Kernel.pm line 2770. > POE::Kernel will poll again after a delay at > /usr/local/lib/perl5/site_perl/5.8.0/POE/Kernel.pm line 2790. > STOP sess 3 > dispatching ET_SIGNAL (IDLE) to session raef-3ef34807a03d > (POE::Kernel=ARRAY(0x8304598)) at > /usr/local/lib/perl5/site_perl/5.8.0/POE/Kernel.pm line 2407. > propagating compatible signal (IDLE) to session 2 (pinger) at > /usr/local/lib/perl5/site_perl/5.8.0/POE/Kernel.pm line 2451. > propagated to session 2 (pinger) at > /usr/local/lib/perl5/site_perl/5.8.0/POE/Kernel.pm line 2463. > stopping signaled session session 2 (pinger) at > /usr/local/lib/perl5/site_perl/5.8.0/POE/Kernel.pm line 703. > stopping signaled session session raef-3ef34807a03d > (POE::Kernel=ARRAY(0x8304598)) at > /usr/local/lib/perl5/site_perl/5.8.0/POE/Kernel.pm line 703. > STOP KERNEL > > Here is the program and the package: > > use warnings; > use strict; > > sub POE::Kernel::ASSERT_DEFAULT () { 1 } > sub POE::Kernel::TRACE_SIGNALS () { 1 } > > use POE qw( Component::RRDTool Component::Client::Ping); > > use cwexodus::Device; > use Ping; > > sub refresh_index { > my ($kern, $heap) = @_[KERNEL, HEAP]; > my $d = new cwexodus::Device; > my $dev = $d->getDevices(); > my $i = 0; > foreach my $devid (keys %$dev) { > $d->setFocus($devid); > my $a = $d->getAttrs(); > if (($a->{ipaddresses} =~ /^([0-9]{1,3}\.){3}[0-9]{1,3}$/)) > { > $a->{id} = $devid; > $heap->{deviceByIp}->{qq($a->{'ipaddresses'})} = $a; > $heap->{deviceById}->{$devid} = $a; > $heap->{deviceByName}->{qq($a->{'name'})} = $a; > $i++; > } > } > $heap->{deviceNum} = $i; > } > > sub schedule_start { > my ($kern, $heap, $sess) = @_[KERNEL, HEAP, SESSION]; > print "START sess " . $sess->ID . "\n"; > $heap->{deviceById} = {}; > $heap->{deviceByIp} = {}; > $heap->{deviceByName} = {}; > $heap->{deviceNum} = 0; > $kern->yield('refresh_index'); > $kern->yield('ping_start'); > } > > sub schedule_stop { > my ($sess) = $_[SESSION]; > print "STOP sess " . $sess->ID . "\n"; > } > > sub _default { > print "Default caught an unhandled $_[ARG0] event.\n"; > print "The $_[ARG0] event was given these parameters: > @{$_[ARG1]}\n"; > return 0 ; > } > > # COMPONENTS > > POE::Component::Client::Ping->spawn > ( Alias => 'pinger',# The component's name will be "pinger". > Timeout => 5,# The default ping timeout. > ); > > # SESSIONS > > POE::Session->create( > inline_states => { > _start => \&schedule_start, > _stop => \&schedule_stop, > refresh_index => \&refresh_index, > _d
Re: problems using package methods...
Hi Josh, If Ping.pm is a separate file, you need to "use POE" to import the KERNEL, HEAP, etc. constants. Try that and see if things improve. Dan Josh wrote: > > I am having a strange problem w/package methods not seeming to work > properly, at least as far as I understand them. This is my first POE > program, it is a simple program that pings some hosts using > POE::Component::Client::Ping. I am trying to put the event handlers related > to pinging in their own package. If anyone has any ideas or suggestions I > would really appreciate it, bc I have read all the docs and online resource > and this is erally starting to bake my noodle. Example output and the code > is below. > > -josh > > I first wrote the program using inline handlers w/all the coderefs in the > same file. running this works fine: > > # perl daemon.pl > START KERNEL > 216.33.69.110 0.0165859460830688 > 216.33.68.131 0.0180959701538086 > 216.33.69.33 0.0192290544509888 > 216.33.68.132 0.0205649137496948 > 216.33.66.190 0.0219370126724243 > 216.33.66.150 0.0233149528503418 > 64.37.201.22 0.0246679782867432 > 216.33.69.110 : NO RESPONSE > 216.33.68.131 : NO RESPONSE > 216.33.69.33 : NO RESPONSE > 216.33.68.132 : NO RESPONSE > 216.33.66.190 : NO RESPONSE > 216.33.66.150 : NO RESPONSE > 64.37.201.22 : NO RESPONSE > STOP sess 3 > STOP KERNEL > > However, if I move the handlers out of this file to a package and change the > Session's event mapping to use package methods, none of my handlers get > invoked (w/assertions and debuggin this time): > > START KERNEL > POE::Kernel is polling for signals at 1056131081.00576 at > /usr/local/lib/perl5/site_perl/5.8.0/POE/Kernel.pm line 2711. > POE::Kernel has no child processes at > /usr/local/lib/perl5/site_perl/5.8.0/POE/Kernel.pm line 2770. > POE::Kernel will poll again after a delay at > /usr/local/lib/perl5/site_perl/5.8.0/POE/Kernel.pm line 2790. > STOP sess 3 > dispatching ET_SIGNAL (IDLE) to session raef-3ef34807a03d > (POE::Kernel=ARRAY(0x8304598)) at > /usr/local/lib/perl5/site_perl/5.8.0/POE/Kernel.pm line 2407. > propagating compatible signal (IDLE) to session 2 (pinger) at > /usr/local/lib/perl5/site_perl/5.8.0/POE/Kernel.pm line 2451. > propagated to session 2 (pinger) at > /usr/local/lib/perl5/site_perl/5.8.0/POE/Kernel.pm line 2463. > stopping signaled session session 2 (pinger) at > /usr/local/lib/perl5/site_perl/5.8.0/POE/Kernel.pm line 703. > stopping signaled session session raef-3ef34807a03d > (POE::Kernel=ARRAY(0x8304598)) at > /usr/local/lib/perl5/site_perl/5.8.0/POE/Kernel.pm line 703. > STOP KERNEL > > Here is the program and the package: > > use warnings; > use strict; > > sub POE::Kernel::ASSERT_DEFAULT () { 1 } > sub POE::Kernel::TRACE_SIGNALS () { 1 } > > use POE qw( Component::RRDTool Component::Client::Ping); > > use cwexodus::Device; > use Ping; > > sub refresh_index { > my ($kern, $heap) = @_[KERNEL, HEAP]; > my $d = new cwexodus::Device; > my $dev = $d->getDevices(); > my $i = 0; > foreach my $devid (keys %$dev) { > $d->setFocus($devid); > my $a = $d->getAttrs(); > if (($a->{ipaddresses} =~ /^([0-9]{1,3}\.){3}[0-9]{1,3}$/)) > { > $a->{id} = $devid; > $heap->{deviceByIp}->{qq($a->{'ipaddresses'})} = $a; > $heap->{deviceById}->{$devid} = $a; > $heap->{deviceByName}->{qq($a->{'name'})} = $a; > $i++; > } > } > $heap->{deviceNum} = $i; > } > > sub schedule_start { > my ($kern, $heap, $sess) = @_[KERNEL, HEAP, SESSION]; > print "START sess " . $sess->ID . "\n"; > $heap->{deviceById} = {}; > $heap->{deviceByIp} = {}; > $heap->{deviceByName} = {}; > $heap->{deviceNum} = 0; > $kern->yield('refresh_index'); > $kern->yield('ping_start'); > } > > sub schedule_stop { > my ($sess) = $_[SESSION]; > print "STOP sess " . $sess->ID . "\n"; > } > > sub _default { > print "Default caught an unhandled $_[ARG0] event.\n"; > print "The $_[ARG0] event was given these parameters: > @{$_[ARG1]}\n"; > return 0 ; > } > > # COMPONENTS > > POE::Component::Client::Ping->spawn > ( Alias => 'pinger',# The component's name will be "pinger". > Timeout => 5,# The default ping timeout. > ); > > # SESSIONS > > POE::Session->create( > inline_states => { > _start => \&schedule_start, > _stop => \&schedule_stop, > refresh_index => \&refresh_index, > _default => \&_default, > }, > package_states => [ > Ping => [qw(ping_start pong)], > ], > ); > > print "START KERNEL\n"; > POE::Kernel->run(); > print "STOP KERNEL\n"; > > # HERE IS THE Ping.pm