On Thu, Sep 06, 2001 at 04:12:04PM -0700, Todd Caine wrote:
> Hello,
> 
> I'm using POE::Wheel::Run to pipe, fork, and exec a program
> that reads from stdin.  Every couple of minutes I have lots
> of data for the command to process.  My question is this:

Actually, it's many questions.  I'll split them up.

> Is it possible for me to send too much data too fast down the pipe
> to the child process?

Well, yes.  While Wheel::ReadWrite does sysread and syswrite on
non-blocking pipes (or sockets) internally, you can easily write much
more data than is practical.  Whatever isn't flushed at the next
opportunity gets buffered for later.

> If so will this generate a sigpipe?

No.

> If not, where is the buffering taking place and how large is the
> buffer?

I imagine some buffering happens in the operating system.  The
remainder occurs in a list that's hidden within POE::Driver::SysRW.
The too-fast problem happens when you let the wheel's buffer eat all
your memory.

> The command that was exec()d does block until it is finished
> processing each work request.
> 
> I'm doing something similar to:
> 
> while (@work) {
>     $heap->{child}->put(shift @work);
> }
> 
> Is this OK?

Yes, but it's not a really good way to do that.  Wheel::Run's put()
method will iterate over what it's given, so you could just write
$heap->{child}->put(@work).

To avoid flooding the wheel's output buffer (the child's input
buffer), see if the child will emit messages that acknowledge when a
job is done.  Avoid sending more than one job at a time, instead
sending the next job after the child says the last one finished.

-- Rocco Caputo / [EMAIL PROTECTED] / poe.perl.org / poe.sourceforge.net

Reply via email to