Re: retry a Poe::Wheel::ReadWrite->put()

Seth Daniel <[email protected]>
Newsgroups gmane.comp.lang.perl.poe
Message-ID <[email protected]>
On Sat, Sep 27, 2008 at 11:45:57PM +0200, Martijn van Beers wrote:
> On Sat, 2008-09-27 at 14:16 -0700, Seth Daniel wrote:
> > Hi,
> > 
> > Once the child session performs a put(), the write will fail and I
> > receive an ErrorEvent.  I don't seem to be able to get the data that was
> > in the original put().  So, if I buffer the data, perform the put(), and
> > then receive an error I can use the wheel_id to identify the data that
> > failed to be written.  However, I don't get an event when the write is
> > successful so it doesn't seem like I can remove items from the buffer.
> 
> You can sign up for Wheel::ReadWrite's FlushedEvent, just like you had
> to to receive the ErrorEvent.

This seems to work well, but only if I have a new ReadWrite wheel for
each write (my initial plan was to have a single ReadWrite wheel for the
lifetime of the session).  This way the write queue is guaranteed to
either be flushed or have an error.  I can also use a ReadWrite wheel
for some set amount of writes and then expire the wheel.  This saves me
from having to potentially create  millions of ReadWrite wheels over the
lifetime of the server.   

So buffering the data to be written and expiring ReadWrite objects works
pretty well.  My only question would be: is this really the best way to
'retry' writes?  Seems like there should be an easier way.

  
-- 
seth /\ sethdaniel.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.