I have tried a number of different things. Immediately after I sent my post
I noticed the missing LF. I have added that and I still get no return value.
Inline comments...

From: "Rocco Caputo" <[EMAIL PROTECTED]>
> On Thu, Mar 14, 2002 at 01:45:28AM -0800, Ryan White wrote:
> > I am looking for an example using Wheel::Run within a child process. I
need
> > to know how to read the output of a Wheel after using put.
[..]
> >
> > sub child_start {
> >   my ($kernel, $session, $parent, $heap, $email) = @_[KERNEL, SESSION,
> > SENDER, HEAP, ARG0];
> >
> >   # Remember the parent.
> >   $heap->{parent} = $parent;
> >
> >   warn "Child ", $session->ID, " will validate $email.\n";
> >
> >   # Check the passed email address.
> >
> >   my $program = [ "./check_addr.pl" ];
> >   my $wheel = POE::Wheel::Run->new(
> >                   Program    => $program,
> >                   StdoutEvent => &stdout, # Event to emit with child
stdout

I have also tried using 'stdout' but it never calls the stdout method..
Where should the stdout method be defined. I had the following in my creat
child function:
sub create_a_child {
  my $email = shift;
  POE::Session->create
    ( inline_states =>
      { _start  => \&child_start,
        _stop   => \&child_stop,
        stdout  => \&child_stdout,
      },
      args => [$email],
    );
}

Is this not the correct method? When I used this code it would never call te
child_stdout method. Which session does it need to be in?

[..]
> > }
>
> I see two problems here:
>
> First, you are not storing the new POE::Wheel::Run instance in $heap,
> so it's destructing as soon as child_start() returns.

I didn't see anything in the POE::Wheel::Run docs about putting the instance
in $heap. What is the convention for that

> Second, your StdoutEvent should be an event name, not a code
> reference.
>
> [...]
>
> > And the check_addr.pl program simply looks like this
> > #!/usr/bin/perl
> > my $email = <>;
> > chomp($email);
> > print 1;
> >
> > It doesn't seem to ever be able to read the data that check_addr sends
back.
> > Should I be doing this another way?

Ok the script now looks like this
#!/usr/bin/perl
use strict;
$| = 1;
my $email = <>;
chomp($email);
print "1\n";

I over simplified the script so that it only test the wheel processes. I am
attaching the scripts so that you can see if I'm missing something easier.
What I think it happening (not sure if it make sense) is the child it
calling the wheel but has nothing else to do so it then exits before getting
stdout.

Attachment: wheel_test.pl
Description: Binary data

Attachment: check_addr.pl
Description: Binary data

Reply via email to