ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-poe
perl-poe
Re: Flushing a FollowTail wheel.
by Rocco Caputo other posts by this author
Nov 24 2006 1:49PM messages near this date
Flushing a FollowTail wheel. | object_states 2
On Nov 21, 2006, at 21:18, Mark Swayne wrote:

>  Is it possible to flush the contents of a POE::Wheel::FollowTail  
>  wheel?
> 
>  I am using one to monitor a file that is left with a non '\n'  
>  terminated line at when the process that creates it is finished.
> 
>  What I'd like to be able to do before closing is somthing like:
> 
>  sub finish_file {
>    my $heap = $_[HEAP];
>    $heap->{wheel}->flush;  # this should generate an InputEvent with  
>  any dangling bits left in the buffer.
> 
>    # do other stuff here
>  }

If Wheel::FollowTail had a set_filter() method, you could use it to  
switch to POE::Filter::Stream.  That would get you a final InputEvent  
with whatever remained in the buffer.  On your end, the code would be:

sub finish_file {
   my $heap = $_[HEAP];
   $heap-> {wheel}->set_filter( POE::Filter::Stream->new() );
   # ...
}

I've attached an untested patch for set_filter().  Let me know if it  
works, and I'll commit it.

-- 
Rocco Caputo - rcaputo@pobox.com
Thread:
Mark Swayne
Rocco Caputo

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved