Problems sending to stdin of POE::Wheel::Run-spawned process

2004-12-20 Thread Dan McCormick
Hi,

Shouldn't the code below print 1, 2, 3, 4 on separate lines to the file
/tmp/test.txt?

If I comment out lines 537-538 of POE::Wheel::Run.pm, namely:

  $poe_kernel->select_pause_write($self->[HANDLE_STDIN])
unless ($self->[OCTETS_STDIN]);

... things work as (I) expected.  Some cursory debugging suggests POE isn't
flushing the buffer when the state returns, as the docs indicate.

This behavior holds for the following tested systems, all running POE
0.3003:

Mac OS X Perl 5.8.1
Redhat 7.3 Perl 5.6.1
Redhat 9.0 Perl 5.8.0

Also, even with the commented-out lines, it looks like I still need the
'doit' and 'shutdown' events to be separate (i.e., combining everything into
the _start event doesn't work).  Is that behavior intentional?

Thanks,
Dan

#!/usr/bin/perl

use strict;
use POE qw(Wheel::Run);

POE::Session->create(
package_states => [
main => [qw( _start _stop doit shutdown err stderr close)]
]
);
$poe_kernel->run();

sub _start {
my $heap = $_[HEAP];

$heap->{wheel} = POE::Wheel::Run->new(
Program => '/bin/cat > /tmp/test.txt',
StderrEvent => "stderr",
ErrorEvent => "err",
CloseEvent => "close",
);

$_[KERNEL]->yield("doit");
}

sub doit {
my ($kernel, $heap) = @_[KERNEL, HEAP];
print "Created wheel " . $heap->{wheel}->ID . "\n";

print "Sending...\n";
$heap->{wheel}->put( "1" );
$heap->{wheel}->put( "2" );
$heap->{wheel}->put( "3" );
$heap->{wheel}->put( "4" );

$kernel->yield('shutdown');
}

sub shutdown {
my $heap = $_[HEAP];

print "Shutting down...\n";
$heap->{wheel}->shutdown_stdin();
}

sub _stop {
}

sub stderr {
my ($input, $wheel_id) = $_[ARG0]..$#_;
print "stderr from wheel $wheel_id: $input\n";
}

sub err {
my ($input, $wheel_id) = $_[ARG0]..$#_;
print "Error from wheel $wheel_id: $input\n";
}

sub close {
my ($wheel_id) = $_[ARG0]..$#_;
print "Close from wheel $wheel_id\n";
}





Re: New user; some input

2004-12-20 Thread nadim khemir
David Davis wrote:

> Hi Nadim,
> Welcome to POE :)
Thank you. 

> On Mon, 20 Dec 2004 01:49:25 +0100, nadim khemir <[EMAIL PROTECTED]> wrote:

>> POE::Component::Child doesn't install without force as it want to run
>> less tests than planned.
> 
> Yes, I reported this to the author before, and he still hasn't fixed it.
> (Maybe he'll read this)
He does :-) He requested info that I already have send.
 
> Is POE::Component::Player::Mpg123 the module you are talking about?
> It's by the same author, and its also broken. (Erick! Can we get this
> fixed?)
No, POE::Component::Mpg123 which is used in the example on the POE web site.

> If you are looking to control an mp3 player, you can also look at
> POE::Component::Player::Xmms.  I wrote it so if you need help, just
> let me know.
It installed and ran the test without problems. This was good as my xmms was
broken since, well since I upgraded perl and Mandrake went bersek. I took
the time to reinstall it and except the instability of the visualization
plugins it works fine. which also gave me the opportunity to test with some
real cool jazz. The only problem is that it's so good you stop the
programming to listen :-)

Bud Powell Trio - Night In Tunisia.mp3
Al Jarreau - Agua De Beber
Cidade Vazia - Milton Banana Trio
Jimmy Smith - Messy Bessie 

A silly question. Why a module to control an application that can run
separately and has a GUI?

> It may not be what you want if you are strickly wanting a curses based
> program.
That was my goal but the real goal is the road the goal.

If someone knows of a good POE/Curses example, please let me know.





PoCo SNMP: a couple questions

2004-12-20 Thread Jim
I'm new to POE, so this could be relatively simple. My apologies if it 
is, my search efforts turned up empty as I'm not sure what question to ask.

Largely to learn POE, I'm doing a proof-of-concept with POE and 
PoCo::SNMP to gather SNMP data from a couple thousand switches and store 
it to a SQL database.

The short story of the flow (this example will be for just one switch):
The main session _starts by creating a PoCo::SNMP instance that grabs a 
list of VLANs from the switch. For each of those VLANs, there's a 
session created to grab four other OIDs based via a 
community-string-indexed request. This all verified to work fine.

I'm getting hung up on knowing when these last four OIDs are done. If I 
post a "finish" message to the end of the queue and try to process the 
data in a _stop event, the SNMP session is torn down before all of its 
data is retrieved. Without a "finish" the SNMP session doesn't die and 
the session (properly, I think) stays running.

I'm not sure I'm on the right path with my design anyway, so any 
suggestions would be much appreciated.

Cheers,
Jim