Re: poe.perl.org down?

2009-07-14 Thread David Davis
Have you tried talking HTTP to it? :)

It works for me.  Could you elaborate on the problem?

David Davis
☄ Software Engineer
http://xant.us/
http://xantus.tel/


On Tue, Jul 14, 2009 at 14:33, Larry Clapp  wrote:

> I can't get poe.perl.org to talk to me.  Anyone know why?
>
> -- Larry
>


Re: Use of POE within a module

2009-04-28 Thread David Davis
I'd look here: http://search.cpan.org/dist/POE/
and Start with POE::Kernel and POE::Session

The POD docs are the most recent.

Cheers

David Davis
☄ Software Engineer
http://xant.us/
http://xantus.tel/


On Tue, Apr 28, 2009 at 19:38, howard chen  wrote:

> Hello,
>
> On Wed, Apr 29, 2009 at 2:08 AM, David Davis 
> wrote:
> > Replace 'main' with MyModule and remove MyModule from your function
> names.
> >
> > You should also read the docs.
> >
>
> Yes, but the POE doc are quite scatterred
> (http://poe.perl.org/?POE_Documentation), and many are old works, so I
> am not sure which one I should read.
>
> Any suggestions?
>


Re: Use of POE within a module

2009-04-28 Thread David Davis
Replace 'main' with MyModule and remove MyModule from your function names.

You should also read the docs.

David Davis
☄ Software Engineer
http://xant.us/
http://xantus.tel/


On Tue, Apr 28, 2009 at 10:00, howard chen  wrote:

> Hello,
>
> Most example put callback function as global, e.g.
>
>
> http://search.cpan.org/dist/POE-Component-Client-NNTP/lib/POE/Component/Client/NNTP.pm
>
> POE::Session->create(
>package_states => [
>'main' => { nntp_disconnected => '_shutdown',
>nntp_socketerr=> '_shutdown',
>nntp_421  => '_shutdown',
>nntp_200  => '_connected',
>nntp_201  => '_connected',
>},
>'main' => [ qw(_start nntp_211 nntp_220 nntp_223
> nntp_registered)
>],
>],
>   );
>
>
>
> How about if the callback I want to call the fucntion inside a module?
>
> POE::Session->create(
>package_states => [
>'main' => {
>nntp_disconnected => 'MyModule::_shutdown',
>nntp_socketerr=> 'MyModule::_shutdown',
>nntp_421  => 'MyModule::_shutdown',
>nntp_200  => 'MyModule::_connected',
>nntp_201  => 'MyModule::_connected',
>},
>'main' => [
>qw(MyModule::_start MyModule::nntp_211
> MyModule::nntp_220
> MyModule::nntp_223 MyModule::nntp_registered)
>],
>],
>);
>
> Of cause the above one is not correct.
>


Re: Suggestions on which poe DBI module to use

2009-04-27 Thread David Davis
I'd like to take a look at PoCo-EasyDBI-Multiplex.

Btw, I'm the EasyDBI author, so you can direct any questions about it to the
list.

David Davis
☄ Software Engineer
http://xant.us/
http://xantus.tel/


On Mon, Apr 27, 2009 at 12:16, Phil Whelan  wrote:

> Hi,
>
> I like POE-Component-EasyDBI
>
> Actually, I've written a wrapper module
> POE-Component-EasyDBI-Multiplex, which I've not yet made public, but
> we're using to manage a pool of EasyDBI connections.
> POE-Component-EasyDBI-Multiplex uses the same interface as
> POE-Component-EasyDBI, but the whole API is not fully support - we
> just implemented what we needed. I can send the code to the list if
> anyone is interested in using it. Hopefully, will get around to
> packaging it up sooner or later.
>
> Thanks,
> Phil
>
> --
> Twitter: http://www.twitter.com/philwhln
>
>
> On Mon, Apr 27, 2009 at 11:54 AM, Josh803316  wrote:
> > I've read the cpan module docs and have looked at the cookbook example (
> > http://poe.perl.org/?POE_Cookbook/DBI_Helper_Processes). The following
> > modules all run non-blocking async dbi calls for poe but I'm not sure
> which
> > I should choose.  I would love to see a pro/con list for these or get
> some
> > sort of guidance on which would work better in my network testing app.
> >
> > I'm sure everyone has favourites out there, but is there any reason to
> use
> > one over another in certain scenarios?  Are there any drawbacks or things
> to
> > watch out for on specific modules?
> >
> > POE::Component::LaDBI
> >
> > POE::Component::EasyDBI
> >
> > POE::Component::DBIAgent
> >
> > POE::Component::SimpleDBI
> >
>


Re: Is it possible to use POE to develop COMET based web app?

2009-04-02 Thread David Davis
Yes it's possible.  I've built a few iterations of comet servers in POE over
the years, but mine are mostly specialized for socket proxying.

What you really want is Eric Waters' module POE::Compoent::Server::Bayeux

http://search.cpan.org/~ewaters/POE-Component-Server-Bayeux-0.02/lib/POE/Component/Server/Bayeux.pm<http://search.cpan.org/%7Eewaters/POE-Component-Server-Bayeux-0.02/lib/POE/Component/Server/Bayeux.pm>
It comes with a client too
http://search.cpan.org/~ewaters/POE-Component-Server-Bayeux-0.02/lib/POE/Component/Client/Bayeux.pm<http://search.cpan.org/%7Eewaters/POE-Component-Server-Bayeux-0.02/lib/POE/Component/Client/Bayeux.pm>

If you download the package from here:
http://search.cpan.org/~ewaters/POE-Component-Server-Bayeux-0.02/<http://search.cpan.org/%7Eewaters/POE-Component-Server-Bayeux-0.02/>,
you'll find an htdocs dir with examples in it.
Demos like: chat, magnets, echo, time, etc

HTH

David Davis
☄ Software Engineer
http://xant.us/


On Wed, Apr 1, 2009 at 20:14, Roy M.  wrote:

> Hello,
>
> Read through the cookbook and found POE is very powerful!
>
> However, is it possibe to provide some hints/tutorial on developing
> COMET based web app?
>
> E.g. simple chat or echo, such as:
> http://blogs.divmod.com/2008/05/twisted-ajaxcomet-tutorial-pre-release.html
>
> It should be very useful.
>
> Thanks!
>


Re: Help with POE::Filter::JSON

2008-10-27 Thread David Davis
Your works for me, if there is a \n at the end of the file.
Since you are stacking Line and JSON, you need a line feed at the end.

The POE::Filter::JSON author,

David Davis
☄ Software Engineer
http://xant.us/


On Mon, Oct 27, 2008 at 06:54, Votava, Craig M (Craig) <
[EMAIL PROTECTED]> wrote:

> Folks-
>
>
>
> I'm trying to learn how to use POE::Filter::JSON, but am having some
> problems (none of the input is being un-JSON-ified).
>
>
>
> Attached is my code so far.
>
>
>
> Any suggestions or pointers are much appreciated.
>
>
>
> Thanks
>
>
>
> -Craig
>
>
>
> Use this as the contents of the input file (or any json input):
> {"Text":["Hi there...","How are
> you?","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15",
> "16","17","18","19","20","21","22","23","24","24","26","27","28","29"]}
>
> Here is the script:
> use strict;
> use warnings;
>
> use Tk; # This MUST come before use POE...
> use POE;
> use POE::Wheel::FollowTail;
> use POE::Filter::Stackable;
> use POE::Filter::Line;
> use POE::Filter::JSON;
> use Data::Dumper;
>
> my $infile = shift || die "Missing Input File...";
>
> _displayData();
>
> my $sess = _processData($infile);
>
> # This should simply create a dummy postback on the tail session
> my $subref = $sess->postback('DontDie');
>
> print STDERR "STARTING to process data...\n";
> POE::Kernel->run;
> exit;
>
> sub _processData{
>my $ifile=shift || die "Missing input file";
>POE::Session->create(
>inline_states=>{
>_start=>sub {
>my $filters;
>print "Session ", $_[SESSION]->ID, " has started.\n";
>$_[KERNEL]->alias_set("myClient");
>my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
># Setup filters in filter stack...
>$filters = POE::Filter::Stackable->new(
>Filters=>[
>POE::Filter::Line->new(),
>POE::Filter::JSON->new(
>json_any => {
>allow_nonref =>1,
>},
>),
>],
>);
>$_[HEAP]->{wheel}=POE::Wheel::FollowTail->new(
>Seek=>0,
>Filename=>$ifile,
>InputEvent=>'display',
>Filter=> $filters,
>);
>},
>display => sub{
>InputEvent=>$_[KERNEL]->post(Display=>data=>$_[ARG0]),
>},
>sendStop   => sub{
>print "Stopping file input\n";
>my $heap = $_[HEAP];
>delete $heap->{wheel};
>},
>},
>),
> }
>
>
> sub _displayData{
>
>my $hwid = shift;
>my $text;
>
>POE::Session->create( inline_states => {
>_start => sub {
>$_[KERNEL]->alias_set("Display");
>my $kernel=$_[KERNEL];
>
>my $top = $poe_main_window;
>
># Create Stop button...
>$top->Button(-text=>"Stop", -command=>sub{
>&stop($kernel);
>$top->update;
>} )->pack(-side=>'bottom');
>
># Create top level Tree...
>$text = $top->Scrolled('Text',
>-scrollbars=>'osow')->
>pack(-fill=>'both', -side=>'left',
>   -expand=>1);
>
>},
>data=>sub{
>my $node=$_[ARG0] || return;
>#my $txt = join("\n", @{$node->{Text}});
>$text->insert('end', Dumper($node) . "\n");
>
>$text->update;
>},
>});
> }
>
> sub stop{
>my $ker = shift;
>if ($ker){
> print STDERR "Sending sendStop to myClient\n";
>$ker->call("myClient","sendStop");
>}
> }
>
>


Re: POE::XS::Loop::Poll (again)

2008-08-04 Thread David Davis
Look at $poe_kernel->poe_kernel_loop();

David Davis
☄ Software Engineer
http://xant.us/


On Mon, Aug 4, 2008 at 08:24, hideo <[EMAIL PROTECTED]> wrote:

> Tony Cook (Mon 08/04/08 22:39):
> > In the spirit of POE::XS::Queue::Array, I've released
> > POE::XS::Loop::Poll, an implementation of POE's event loop written in
> > C.
> >
> > I haven't done any speed benchmarks (or found any), but I expect it to
> > be slightly lower overhead than the built-in POE::Loop::Select.
> >
> > Of course, without a benchmark it can only be a guess.
> >
> > Unfortunately, due to an apparent limitation with Darwin's poll(2)
> > implementation you can't use this loop with ttys under Darwin.[1]
> >
> > The nopaste bot on irc.perl.org has been using POE::XS::Loop::Poll
> > since the 0.005 release.
> >
> > Tony
> >
> > [1] From poll(2):
> >   BUGS
> >  The poll() system call currently does not support devices.
> > which is kind of vague, but calls result in POLLNVAL set for the tty fds.
>
> Does API::Peek report this loop properly?  I can't seem to verify that
> POE is using XS::Loop::Poll or not.
>
> Zach
>


Re: Filter::SSL and filter metadata handling

2008-07-19 Thread David Davis
Well, my 'try' was successful.  AFAIK, it was the first full
non-blocking ssl filter.
We have yet to have the changes we made make it into POE core though :)

I'm glad you're spear heading this, and Data::Transform is a good
choice. I'm ok with a patch to Wheel::ReadWrite as long as it is
backward compatible and the performance penalty is minimal.

What does everyone else think?

David Davis
☄ Software Engineer
http://xant.us/


On Sat, Jul 19, 2008 at 10:38, Martijn van Beers <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've been working on a filter to do SSL, inspired by David Davis' try in
> Sprocket and IO::Socket::SSL. It seems to be working pretty well (see
> attached code; mostly needs more testing and error handling), but I
> can't release it because it needs more API than filters currently
> provide (see also the 'POE::Filter error reporting' thread)
>
> My current thoughts are to forget about trying to extend POE::Filter but
> start over in a new namespace (possibly Data::Transform?) That way
> there's no need to worry about mixing up filters with the old and new
> apis. And not being in the POE namespace might help convince people that
> Filters really are useful outside of POE.
>
> Of course, there is still need for handling this in Wheel::ReadWrite
> (and other wheels) too. Not sure whether to subclass those or to add
> some extra if blocks.
>
> I'm mostly writing this email to find out what people think of the idea
> of doing 'new filters' in a new namespace (and if so, which namespace).
> But if you think I'm on crack for how I'm doing things in Filter::SSL,
> please let me know that too :)
>
>
> Martijn
>


Re: SSL ?

2008-04-29 Thread David Davis
Yes, there is such a module.

You can find it here, by searching for POE SSL
http://search.cpan.org/

This is me holding back the urge to flame you, but it may not stop others :)


On Tue, Apr 29, 2008 at 3:50 AM, lanas <[EMAIL PROTECTED]> wrote:

> Folks,
>
>  This is a general question since I haven't done any search on this
> yet.  Is there a module that would provide SSL (or some similar) feature
> that would integrate with POE basic network communications ?
>
> Thanks for any suggestions.
>
> Al
>



-- 
David Davis
☄ Software Engineer
http://xant.us/


Re: Alternative for Apache ?

2008-01-21 Thread David Davis
If the web server must be poe, then you can try Sprocket (it uses POE)

Here is the quick and dirty way to get running.
Check out sprocket from svn:

$ svn co http://svn.xantus.org/sprocket/trunk/Srpocket sprocket
$ cd sprocket
$ perl examples/cgi_http.pl

(satisfy deps until it runs)

I haven't run php with it yet, but I'm sure cgi mode would work fine.

Cheers,

David

On Jan 20, 2008 3:29 PM, abhishek jain <[EMAIL PROTECTED]> wrote:

> Hi Friends,
> Is it a possiblity to create an alternative to Apache via POE.
> It should be scalable.
> I have seen POE cookbook and can not find one satisfying my needs.
> It should have ability to serve Perl/PHP requests.
> The reason behind my this request is i have some requirements which are
> not
> being solved by my existing Apache setup like giving a totally seperate
> enviornment for dynamic virtual hosts.
> Pl. reply,
> Thanks,
> abhi
>



-- 
David Davis
☄ Software Engineer
http://xant.us/


Re: Archiving with POE

2007-11-03 Thread David Davis
That filter is for compressing a stream.  You should look at using an  
archive module in combination with POE::Component::Generic


HTH
Cheers
--
David Davis
• Software Engineer
• [ http://xant.us/ ]

On Nov 3, 2007, at 20:09, "Jeremy Palmer" <[EMAIL PROTECTED]> wrote:


Hi,

Does anyone know if there is an easy way to compress a directory of
files (either with TAR/GZIP or ZIP) using POE? I see there is a filter
called 'POE::Filter::Zlib', but I'm not sure how to use it.

In some cases the directory archive might be 50 mb, so it's very
important that this task does not block the POE server I have.

Thanks
Jeremy

__





This message contains information, which is confidential and may be  
subject to legal privilege.
If you are not the intended recipient, you must not peruse, use,  
disseminate, distribute or copy this message.
If you have received this message in error, please notify us  
immediately (Phone 0800 665 463 or [EMAIL PROTECTED]) and destroy  
the original message.
LINZ accepts no responsibility for changes to this email, or for any  
attachments, after its transmission from LINZ.


Thank you.
__





Re: Wide Finder

2007-11-03 Thread David Davis


It looks like a competition.
He includes lines of code as a metric, which should tell you  
something...


Well, anyway.
As Pierre, a commenter, suggested; you could write a script that runs  
Perl piped with xargs and the -n and -P options.  No POE needed, and  
it would be faster!

--
David Davis
• Software Engineer
• [ http://xant.us/ ]

On Nov 3, 2007, at 8:55, Kevin Scaldeferri <[EMAIL PROTECTED]>  
wrote:


Okay, I gotta wonder, how come no one's submitted a Wide Finder (http://www.tbray.org/ongoing/When/200x/2007/10/30/WF-Results 
) implementation in POE (or any Perl for that matter)?


I spent a few minutes thinking about this, but the problem I had was  
that I didn't know of a way to easily parallelize over multiple  
cores that wasn't going to require me to write a ton of code.  Are  
there some POE modules that I couldn't find that do something like  
forking a number of worker processes, then allowing me to send  
events between them?



-kevin


Re: Writing an event monitor

2007-08-21 Thread David Davis
Anthony,

If no one is going to feed you the info you need, then you need to research
the docs yourself.
:)

Start with POE::Kernel and the POE::Session docs, and have a look at the
cookbook on poe.perl.org

-- 
David Davis
☄ Software Engineer

On 8/9/07, Anthony R. J. Ball <[EMAIL PROTECTED]> wrote:
>
>
>   No suggestions? I don't need code... I'd just like people's opinions
> on what components/tactics might best suit this task.
>
> >
> >   Hello. I am hoping to replace a sprawling mess of code at
> > our company which is basically an event monitor. Jobs to be run are
> > added for the day and as things heppen they are triggered. POE looks
> > like it and its components would simplify a lot of this, but I was
> > hoping for some guidance as to how to proceed.
> >
> >   A basic outline:
> > * Jobs are added as a lump at the beginning of the day and/or
> >   individually throughout the day (add-ons). Of course, all
> >   could be treated as add-ons
> > * Jobs have what we call wait events, which is basically either
> >   a string, or a four digit number. 4 digit number means do not
> > run before HHMM, string means wait for the event of that name
> > to be posted. (might get posted from external, or from another
> >   job completing)
> > * Jobs call an external command, which does something useful
> > * There are different processing slots, so only X jobs of a certain
> >   type may run at the same time
> >
> >   JobQueue looks promising to replace the slots, in a passive mode...
> >   Wheel::Run looks like it would handle running the jobs nicely...
> >
> >   The main thing I'm not seeing just yet is how to set up the job
> entries
> > with their wait events, then post them along to the proper queue... any
> > monitor may have 1 to over 1000 jobs, depending on the application.
> >
> >   I can think of Perl ways to do this, but I am wondering if there is a
> > more POE-specific way. I have thought of using alert for any timed
> > events but am having difficulty picturing how I should set up the wait
> > events and tick them off one by one, and catching when everything is
> > in place to put the job on the queue.
> >
> >   I would appreciate thoughts/suggestions.
> >
> >
> > --
> >  www.suave.net - Anthony Ball - [EMAIL PROTECTED]
> > OSB - http://rivendell.suave.net/Beer
> > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> > "You can find the way for no one but yourself." - Bradford Shank
> >
> >
> > - End forwarded message -
> >
> > --
> >  www.suave.net - Anthony Ball - [EMAIL PROTECTED]
> > OSB - http://rivendell.suave.net/Beer
> > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> > "Makes me want to write poetry - or bake a ham, I forget which." - Dot
> >
>
> --
>  www.suave.net - Anthony Ball - [EMAIL PROTECTED]
> OSB - http://rivendell.suave.net/Beer
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Earth first!  We'll abuse the other planets later.
>
>


Re: POE::Filter error reporting

2007-08-14 Thread David Davis
7;ll help, promise. Because you have a shit load and I don't
>   blame you for beign resistant to change ;)
> <+LotR> BinGOs: oh no? so what happens if Filter::IRC gets a line that
> doesn't parse?
> <@BinGOs> it warns
> <+LotR> which isn't very nice
> <@BinGOs> and b). I am not using POE::Filter::IRC these days.
> <+LotR> Filter::IRCD then
> <@BinGOs> and c). yes, POE::Filter::IRCD warns
> <+nperez> warnings disappear into the aether and don't control
>   autocorrecting procedures
> <+LotR> BinGOs: which you can't handle very nicely.
> <@BinGOs> Okay, you have a POE::Filter::Stackable
> < imMute> what does PCI use for the client then?
> <@BinGOs> the first filter produces an error, what happens next ?
> <@BinGOs> ( you have four filters in the chain )
> <+nperez> stackable checks the error property, sets its own error
>   property and returns undef
> <+nperez> skipping the other three
> <@BinGOs> do you produce an event at the end ?
> <+LotR> or
> <+LotR> it sticks an error object in the listref out. (and probably
> skips
> the other three filters)
> < imMute> BinGOs: no
> <+LotR> BinGOs: filters don't know anything about POE events. I want to
> keep it that way
> <@BinGOs> PCI uses Filter::IRCD and POE::Filter::IRC::Compat in a
>   stackable.
> < imMute> BinGOs: stackable doesnt produce output unless the last
> filter
>   returns something
> <@BinGOs> SO what happens to your error then ?
> <+nperez> returning undef should be an indicator to check the error
>   property on the filter
> <+LotR> BinGOs: read the scrollback? we've been over this and haven't
> come to an agreement. nperez and I have different views on how
> to
> do it
> <+LotR> but we agree there should be some error reporting in filters
> <@BinGOs> Hell, I'll work around whatever you come up with anyways >:)
> <+nperez> haha
> <@BinGOs> difficult audience.
> <+nperez> Ultimately is up to dngor about an API change
> <+nperez> we are wanting to do something rather fundamental
> <+nperez> especially with a 1.0 approaching
> <@BinGOs> this is why I am stomping my little feet.
> <+nperez> If it's broken, it's broken. Bitching how much the fix hurts
>   isn't going to make it go away :)
> <+LotR> another reason not to do an ->get_error() method. no need to
> change old filters who don't care about error reporting
> <+nperez> if they don't care about error reporting, they aren't
> checking
>   their inputs enough ;)
> <@BinGOs> I am a team player and have a 'Can do attitude'
> <@BinGOs> the whole POE::Filter sub-class thing was no problem to me.
> <+nperez> BinGOs: we aren't interviewing you here. You are more than
>   welcome to be the devil's advocate and general asshole. It
>   helps :)
> <@BinGOs> Yes, I am playing devil's advocate
> <@BinGOs> and yes, I am an asshole.
> <+nperez> You represent a large swath of incumbent modules. Your
> opinion
>   counts
> <@BinGOs> I always have an eye on backwards compatibility.
> <@perigrin> to watch it slip away
> <+nperez> That is certainly something to consider. LotR's idea is
>   probably better for backwards compat
> <@Leolo> backwards compatible with "do nothing useful" is easy
>
>
>


-- 

David Davis
Software Engineer


Re: POE::Kernel patch for propagation of exceptions

2007-07-23 Thread David Davis

Did you submit this to POE's RT?

http://rt.cpan.org/Public/Bug/Report.html?Queue=POE

Cheers,
David

On 7/17/07, Phil Whelan <[EMAIL PROTECTED]> wrote:


Hi,

Where should I send my patch to POE::Kernel? The propagation of
exceptions did not seem to be working as documented.

Thanks,
Phil

--- /usr/local/share/perl/5.8.8/POE/Kernel.pm   2007-07-17
16:54:57.0 -0700
+++ /usr/local/share/perl/5.8.8/POE/Kernel.pm   2007-07-17
16:56:42.0 -0700
@@ -901,7 +901,9 @@
   my $touched_index = 0;
   while ($touched_index < @touched_sessions) {
 my $next_target = $touched_sessions[$touched_index];
-push @touched_sessions,
$self->_data_ses_get_children($next_target);
+push @touched_sessions,
+grep { ref($_) ne 'POE::Kernel' }
+$self->_data_ses_get_parent($next_target);
 $touched_index++;
   }


Test
-

#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 2;
use POE;

POE::Session->create(
inline_states => {
_start => sub {
$poe_kernel->sig(DIE => 'parent_exception');
POE::Session->create(
inline_states => {
_start => sub {
$poe_kernel->sig(DIE => 'child_exception');
$poe_kernel->post($_[SESSION], "throw_exception");
},
throw_exception => sub { die "goodbye sweet world" },
child_exception => sub { pass("child got exception")
},
},
)
},
parent_exception => sub {
pass("parent got exception");
$poe_kernel->sig_handled();
},
_stop => sub { exit },
},
);

POE::Kernel->run();
exit;





--

David Davis
Software Engineer


Re: problem with POE and AIO

2007-07-23 Thread David Davis

Hi,

Are you using PoCo AIO?

Also, I suspect aio might not be writing all the data you're asking it to.
I suggest you make a smaller and simpler test case to isolate your bug.

HTH
Cheers,

David

On 7/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:


i have a web crawler using POE::Component::Client::HTTP that has been
working fine to suck down non-small binary files (pdf, ps, tar.gz,
etc.). i tried to eek out a little more performance by using IO::AIO,
but now about 5% of the downloads are corrupt.  they are the correct
size as indicated by the Content-Length header, but the contents are
invalid data. so i'm guessing that the response data is sometimes
being written out of order.
i know PerlBal does something similar with IO::AIO, so i'm doubting
that  aio threads are messing the order. can anybody see a heisenbug
in my code below? thanks.

sub ua_make_request {
my ($kernel, $heap, $session) = @_[ KERNEL, HEAP, SESSION ];

return if $heap->{is_shutdown};

if ( @{ $heap->{ids} } < $MAX_PARALLEL * 2 ) {
$kernel->yield('dbi_get_urls');
}

my $url= shift @{ $heap->{urls} };

# Check later.
unless ($url) {
$kernel->delay_set( ua_make_request => 60 );
return;
}

# construct HTTP::Request and set $file and $path
...

aio_mkdir( $path, 0777, sub {
my $ret = $_[0];
if ( $ret and not $!{EEXIST} ) {
printf STDERR "%s: $!\n", $path;
return $kernel->post( $session, ua_cleanup_request =>
$req, $ret );
}

my $file = sprintf "%s.tmp", $heap->{req}{$req}{file};
aio_open( $file, O_WRONLY|O_CREAT|O_TRUNC, 0644, sub {
unless ( $heap->{req}{$req}{fh} = $_[0] ) {
printf STDERR "%s: $!\n", $file;
return $kernel->post( $session, ua_cleanup_request =>
$req, -1 );
}
$kernel->post(
ua => request => ua_got_response => $req => "$req",
undef,
$proxy->proxy
);
});
});
}

sub ua_got_response {
my ($kernel, $heap, $session) = @_[KERNEL, HEAP, SESSION];
my ($req, $res, $data) = ( $_[ARG0]->[0], @{ $_[ARG1] } );

# Might have previously cancelled the request.
my $href = $heap->{req}{$req} or return;

if ($res->is_error) {
...
}
elsif (defined $data) {
my ($fh, $file, $got) = @$href{qw(fh file got)};
my $len = do { use bytes; length $data };

$href->{is_writing} = 1;

# Only need to do these tests on the initial response.
if ($got == 0) {
...
}

aio_write( $fh, $got, $len, $data, 0, sub {
my $put = $_[0];

if ($put < 0) {
printf STDERR "Failed to write to %s: $!\n", $file;
$kernel->call( $session, ua_cleanup_request => $req,
-1 );
}
elsif ($put != $len) {
printf STDERR "Only wrote %d / %d bytes for %s\n",
$put, $len,
$file;
$kernel->call( $session, ua_cleanup_request => $req,
-1 );
}
else {
$href->{got} += $len;
$href->{is_writing} = 0;
$href->{response} = $res;

# Call after writing each chunk to avoid a race
condition when
# the last chunk is scheduled to be written, but the
last empty
# response is received before the writing is finished.
$kernel->yield( ua_finish_response => $res );
}
});
}
else {
$href->{is_done} = 1;
$kernel->yield( ua_finish_response => $res );
}
}

sub ua_finish_response {
my ($kernel, $heap, $res) = @_[ KERNEL, HEAP, ARG0 ];
my ($req, $ret) = ( $res->request, -1 );
my $href = $heap->{req}{$req};

return if not $href->{is_done} or $href->{is_writing};

# Prevent race condition.
$href->{is_writing} = 1;

if ($res->is_error) {
...
}
else {
# rename the file
}
}





--

David Davis
Software Engineer


Re: Catching DIE signal from detached sessions

2007-07-18 Thread David Davis

Hi Kenneth,

Please see the docs on this subject at:

http://search.cpan.org/~rcaputo/POE-0.9989/lib/POE/Kernel.pm#Signal_Watcher_Methods
and
http://search.cpan.org/~rcaputo/POE-0.9989/lib/POE/Session.pm#Exceptions

HTH,
David

On 7/18/07, Kenneth Flegal <[EMAIL PROTECTED]> wrote:


I am really hoping that I am just missing something simple with this one
but at the moment I am a bit stumped. I am currently working with
multiple components which are provided with an alias and then detach
from the calling session. This seems to be common practice with the
components available on CPAN. The program that I am writing runs as a
daemon so it is imperative that the program continue and should never
need to die completely due to a problem within one of these aliased
sessions. However in the case that one of these dies I do not have any
sessions that are considered the parent session so the DIE signal goes
uncaught and kills the whole program.



Ideally at this point I would like to create an event to catch any
errors that make it passed any given session regardless of it's parent
to ensure that the program handles an unhandled exception anywhere in
the program. I have been looking through the docs though and don't see
anything that would allow for me to do this since all handlers appear to
be for the session that $kernel->sig() is called in. I also tried
overriding $SIG{'__DIE__'} before doing anything else but this doesn't
seem to be doing the trick either. I would also like to be able to have
all of the information that the kernel exception handler provides when
it catches something which the $SIG{__DIE__} solution wouldn't provide.
Is there a way to do what I am looking for here? I would greatly
appreciate any advice that might point me in the right direction.



- Kenny







--

David Davis
Software Engineer


Re: POE suitability

2007-07-11 Thread David Davis

POE is a cooperative event system, so non of your computations would be
running at the same time.  BUT, you could use POE::Wheel::Run to run them in
a pool of forked children and get the benefit you're looking for.

Cheers,
David

On 7/11/07, Robert Hicks <[EMAIL PROTECTED]> wrote:


In the near future I will be re-writing an app at work. Basically the
app processes emails, parses them for data, and inserts that data into
Oracle. That is pretty basic but that is the flow of it. The data
happens to be nautical computations (heavy math).

I was wondering if I could improve the performance by re-implementing it
in POE so I could process several of those as "events".

Would POE be suitable for something like that?

Robert





--

David Davis
Software Engineer


Re: Win32 Wheel::Run Issues (Reformated)

2007-06-26 Thread David Davis

.9989 is the most recent version of POE

David

On 6/25/07, Jeremy Palmer <[EMAIL PROTECTED]> wrote:


Hi Zack,

Yes I have a resent version of POE installed from CPAN. Version
0.9917.

Thanks
Jeremy

>>> "Zack Payton" <[EMAIL PROTECTED]> 26/06/2007 07:08 >>>

Jeremy,

I assume you are probably running the POE version installed through
ActiveStates ppm.
This seems to have issues and I found that by installing through CPAN
that there is a newer version of POE that seems to have a lot of
performance issues fixed.  Rather than installing through active states
ppm (which seems to be behind a few POE versions), you can install POE
through CPAN:

perl -MCPAN -e "install POE"

See if that helps at all.
Z

On 6/24/07, Jeremy Palmer < [EMAIL PROTECTED]> wrote:Hi,

I'm building a Win32 POE application that need to make a non-blocking
call to a function in an external Perl package. This function takes
references to Perl objects and array references (however no subroutine
refs).

I've looked at the options for completing this sort of task with
POE::Component::Child & Wheel::Run + Filter::Reference, however there
seems to be one limiting factor here - Win32 fork emulation.

The Win32 fork emulation seems very buggy. In tests I've used with
Wheel::Run I get fork failures ( i.e. "fork() failed: Resource
temporarily unavailable") after the 64 calls of fork from the parent
process. See the attached simple example that demos the error:

use strict;
use warnings;

my $COUNT = 0;
my $MAXFORK = 2**6;

while ( $COUNT <= $MAXFORK ) {
my $pid = fork();
die "fork() failed: $!" unless defined $pid;
if ($pid) {
$COUNT++;
print "Fork count $COUNT\n";
}
else {
# in child
exit(0);
}
}

Also when running a code subroutine, passing in variables, with
Wheel::Run and Filter::Reference I get huge memory leaks after the
forked off child thread exits. I can't exactly track where the leaks are
occurring, but it seems to have something to do with including packages
at runtime using the "require" keyword. I also get the same issues with
POE::Component::Child which is no surprise considering it also uses
Wheel::Run + Filter::Reference.

I was hoping if someone might have any suggestions as to how I might
come up with a solution to this problem. Moving from Win32 to *NIX is
not an option.

I have thought about using Win32::Process and running a Perl process in
the background (so the kernel can take responsibility for the memory
allocation etc) and then having a POE delayed event that checks every
second or so to see if the process is complete. I'm however unsure on
how to pass specific runtime variables to the spawned off Perl process.


Any help on fixing POE::Wheel::Run or providing another solution would
be greatly appreciated.

I'm using WinXP SP2, ActiveState Perl v5.8.8 Build 820 and POE 0.9917.

Thanks
Jeremy


__


This message contains information, which is confidential and may be
subject to legal privilege.
If you are not the intended recipient, you must not peruse, use,
disseminate, distribute or copy this message.
If you have received this message in error, please notify us
immediately (Phone 0800 665 463 or [EMAIL PROTECTED]) and destroy the
original message.
LINZ accepts no responsibility for changes to this email, or for any
attachments, after its transmission from LINZ.

Thank you.

__





__

This message contains information, which is confidential and may be
subject to legal privilege.
If you are not the intended recipient, you must not peruse, use,
disseminate, distribute or copy this message.
If you have received this message in error, please notify us immediately
(Phone 0800 665 463 or [EMAIL PROTECTED]) and destroy the original
message.
LINZ accepts no responsibility for changes to this email, or for any
attachments, after its transmission from LINZ.

Thank you.

__



Re: Maximum concurrent TCP connections

2007-06-14 Thread David Davis

We are talking about this on irc at the moment.  I had never used
POE::Loop::Event and assumed it was libevent, but unfortunately it isn't.
We'll get a libevent loop written soon.


David

On 6/5/07, David Davis <[EMAIL PROTECTED]> wrote:


FYI,  POE does have an libevent loop.  POE::Loop::Event


Cheers,
David

On 6/5/07, Bob Maccione < [EMAIL PROTECTED]> wrote:
>
> Event::Lib is a really nice library for doing simple POE-like stuff.
>
> We use a lot of POE but I'm moving some code to Event::Lib due to the
> max connection concerns.  Event::Lib uses the libevent library and seems
> as stable as POE in our current testing.  For our really critical code
> we are using the C api and doing all the work in C.  Perl would probably
> work but C is just safer from a performance standpoint.
>
> Note that this is in the Linux/Solaris world,  I'm not doing a win32
> stuff.
>
> -Original Message-
> From: Rocco Caputo [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 05, 2007 8:48 AM
> To: POE List
> Subject: Re: Maximum concurrent TCP connections
>
> On Jun 4, 2007, at 15:09, Zack Payton wrote:
> >
> > My first question is:  Is 10,000 simultaneous a realistic goal?
>
> Maybe if you combine it with IO::Poll or Event.  The default select()
> loop scales badly because of the way select() works.  Also,
> POE::Component::Server::TCP doesn't use the fastest techniques.  It's a
> generic module first, and optimized for speed second.
>
> > Secondly,  is this a POE issue or an operating system issue?
>
> It's not a POE issue.  POE doesn't care if you try to exceed Perl or OS
> limitations.  It'll just report the error or die trying.
>
> > Is the error mentioned above have anything to do with system level
> > file handles or is it, as the source code documentation mentions, an
> > attempt to mimic the unix mentality of "everything is a file" and it's
>
> > actually a windows socket issue?
>
> No idea there.
>
> --
> Rocco Caputo - [EMAIL PROTECTED]
>
>
>



Re: Maximum concurrent TCP connections

2007-06-05 Thread David Davis

FYI,  POE does have an libevent loop.  POE::Loop::Event


Cheers,
David

On 6/5/07, Bob Maccione <[EMAIL PROTECTED]> wrote:


Event::Lib is a really nice library for doing simple POE-like stuff.

We use a lot of POE but I'm moving some code to Event::Lib due to the
max connection concerns.  Event::Lib uses the libevent library and seems
as stable as POE in our current testing.  For our really critical code
we are using the C api and doing all the work in C.  Perl would probably
work but C is just safer from a performance standpoint.

Note that this is in the Linux/Solaris world,  I'm not doing a win32
stuff.

-Original Message-
From: Rocco Caputo [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 05, 2007 8:48 AM
To: POE List
Subject: Re: Maximum concurrent TCP connections

On Jun 4, 2007, at 15:09, Zack Payton wrote:
>
> My first question is:  Is 10,000 simultaneous a realistic goal?

Maybe if you combine it with IO::Poll or Event.  The default select()
loop scales badly because of the way select() works.  Also,
POE::Component::Server::TCP doesn't use the fastest techniques.  It's a
generic module first, and optimized for speed second.

> Secondly,  is this a POE issue or an operating system issue?

It's not a POE issue.  POE doesn't care if you try to exceed Perl or OS
limitations.  It'll just report the error or die trying.

> Is the error mentioned above have anything to do with system level
> file handles or is it, as the source code documentation mentions, an
> attempt to mimic the unix mentality of "everything is a file" and it's

> actually a windows socket issue?

No idea there.

--
Rocco Caputo - [EMAIL PROTECTED]





Re: POE & Tk excessive CPU usage

2007-05-02 Thread David Davis

POE::Loop::TkActiveState is using select with a timeout of 0.  That doesn't
look right to me.

 my $hits = select(
   my $rout = $loop_vectors[MODE_RD],
   my $wout = $loop_vectors[MODE_WR],
   my $eout = $loop_vectors[MODE_EX],
   0,
 );

David

On 5/2/07, John R. <[EMAIL PROTECTED]> wrote:


John R. wrote:
> I just joined the mailing list...sorry about then new thread...
>
> I am experiencing the same problem: single CPU / 100% utilization when
> idle.
>
> POE:  0.99.89
> Tk:  804.027
> Perl: v5.8.8 built for i686-linux
>
> John
>

strace snippet:

gettimeofday({1178152425, 688201}, NULL) = 0
gettimeofday({1178152425, 688279}, NULL) = 0
select(5, [4], [], [], {0, 0})  = 0 (Timeout)
gettimeofday({1178152425, 688355}, NULL) = 0
gettimeofday({1178152425, 688387}, NULL) = 0
select(5, [4], [], [], {0, 0})  = 0 (Timeout)

That pretty much is in a loop.

John



Re: Newbie Help: Inter-session data transfer

2007-04-24 Thread David Davis

You may want to look at POE::Component::IKC

http://search.cpan.org/~gwyn/POE-Component-IKC-0.1904/IKC.pod

HTH

Cheers
David

On 4/24/07, Craig Votava <[EMAIL PROTECTED]> wrote:


Folks-

First of all, thanks to everyone involved with POE! I've
just been learning about it and am anxious to retrofit
some of my existing tools to use it. It's fantastic!

I'm struggling with choosing the right design alternative
while still being in the dark about what all my available
options might be.

Basically, I have a tool that parses ascii data, organizes
it into appropriate "things", then slaps them up in a GUI
(using ptk) and let's the user have at them. The current
implementation reads all the input first, then goes into
the GUI mainloop.

I want to change this so that the tool handles realtime
input of the data, parsing it as it comes in, then feeding
it to the GUI.

I've gone through the (excellent) "Evolution of a POE
Server" (http://poe.perl.org/?Evolution_of_a_POE_Server),
and have successfully built my POE based data input
session. I've also built a simple POE based GUI session
for displaying the input in a text window (based on
the cookbook "Tk Interfaces").

Now I'm wondering how I should get the data from the
input session to the GUI session? This is what I refer
to as inter-session data transfer.

In my original design, I implemented a version of the
publisher/subscriber pattern as a perl package for my
own use. Should I simply use this? Are there any other
options out there that I should consider?

Any thoughts are appreciated!

Thanks

-Craig Votava
Alcatel-Lucent



Re: POE::Component::Server::HTTP, Keep alive, and leaking sockets

2007-03-23 Thread David Davis

I used 'sudo ngrep port 32080' and watched ls /proc//fd/ while I hit
the http server.
I noticed that the responses were HTTP/1.0 but I didn't see a connection:
close header.
So, I set $response->protocol( "HTTP/1.1" ); in the cookbook example, and
the sockets didn't leak!

I think we have a few options
1) The server should assume connection: close if the protocol is < 1.1 and
no keepalive is being used.
2) The PoCo could set HTTP/1.1 in the response by default.
3) both.

I haven't dug any deeper yet, but it's a good start.

Comments?

David

On 3/23/07, Rocco Caputo <[EMAIL PROTECTED]> wrote:


Something doesn't add up.  Maybe I'm missing a pertinent fact.

On one hand, if sockets are being kept alive between requests, why is
Firefox opening a new socket for each request?

On the other hand, if Firefox is opening a new socket for each
request, why isn't it closing the old ones?

Why isn't Firefox also running out of file descriptors, if it's
opening new sockets without closing old ones?

--
Rocco Caputo - [EMAIL PROTECTED]


On Mar 21, 2007, at 15:50, Eric Busto wrote:

> Firefox seems to keep them alive as well.  Unfortunately, since the
> app
> I am writing uses a meta refresh every few seconds to have the browser
> reload it, a browser left up overnight will easily cause the app to
> run
> out of file descriptors.
>
>   -Original Message-
>   From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Mathieu Longtin
>   Sent: Wednesday, March 21, 2007 12:27 PM
>   To: Eric Busto
>   Cc: poe@perl.org
>   Subject: Re: POE::Component::Server::HTTP, Keep alive, and
> leaking sockets
>
>
>   My memory is fuzzy, but I think if you close the browser,
> especially if it's local, the sockets closes. I remember IE keeping
> the
> connections alive for a while.
>
>
>   On 3/21/07, Eric Busto <[EMAIL PROTECTED]> wrote:
>
>   From what I have gathered, for a web server to be HTTP
> 1.1 compliant, it
>   must support keep alive, and keep alive is enabled by
> default.
>
>   When using POE::Component::Server::HTTP in its simple
> case, as in the
>   cookbook entry
>
> http://poe.perl.org/?POE_Cookbook/Web_Server_With_Components, keeping
>   the connections open even after the event for the URL
> request has been
>   handled causes file descriptors to "leak" as the socket
> will not get
>   closed.
>
>   I can force the connection to get closed after the
> ContentHandler
>   triggers by having a PreHandler like so:
>   POE::Component::Server::HTTP->new (
>   Port=> 80,
>   PreHandler  => {
>   '/' => sub {
> $_[0]->header(Connection =>
>   'close') }
>   },
>   ContentHandler  => {
>   '/' => \&web_status,
>   }
>   }
>
>   My question is, is this the "right" thing to do?  Is
> there a more
>   elegant method, or am I missing something that should be
> obvious?  If
>   I'm not missing anything, should this be added to the
> cookbook page for
>   a basic web server with PoCo::Server::HTTP?



Re: confused about POE::Component::Generic

2007-03-04 Thread David Davis

You are missing a result state in your session.  add result => \&result

Cheers
David

On 3/4/07, Michael Hare <[EMAIL PROTECTED]> wrote:


Does anyone have a concise working example of POE::Component::Generic to
base some testing off of?  I don't fully understand what needs to be
done with the Net::Telnet example synopsis on CPAN to make it
functional.  At a minimum, I'm guessing I need to encapsulate the entire
thing around a POE::Session->create.

I've glanced at Generic/Net/SSH2.pm and it seems a little too abstract
for me to initially get my fingers around.  I looked in the POE cookbook
and that's empty, too.

The reason I'm getting in over my head is that I've been happily using
Component::Ping for awhile now but it lacks IPv6 functionality, and I'd
like to monitor v6 stuff in our net.  I'm trying to decide whether I
should focus on seeing if I can bring Client::Ping up to snuff or to
investigate Component::Generic.  It seems that learning
Component::Generic would be, at this point, the most fruitful thing to do.

Below is where I'm at.  It seems like 'good things' are happening [Ie,
if I tcpdump, I see a telnet conversation with the remote host
occurring], but the sub 'result' never seems to fire and the POE _stop
handler is called.  I don't think I fully understand how interaction is
supposed to occur; what causes Net::Telnet to send back results, and why
is POE exiting when the generic spawn seems like it should still be
waiting for an event?

-Michael

use POE;
use POE::Component::Generic;
use strict;
use warnings;

my $telnet = POE::Component::Generic->spawn(
package => 'Net::Telnet',
alias => 'telnet',
#   debug => 1,
#   verbose => 1,
#   options => { trace => 1 },
);

POE::Session->create(inline_states => { _start => \&start_telnet, _stop
=> \&stop_telnet});
$poe_kernel->run();
print "completed\n";

sub start_telnet {
   print "started\n";
   $telnet->open( { event => 'result' }, "140.189.132.16");
}

sub stop_telnet {
   print "stopped\n";
   $telnet->shutdown();
}

# result state
sub result {
   my ($kernel, $ref, $result) = @_[KERNEL, ARG0, ARG1];
   if( $ref->{error} ) { die join(' ', @{ $ref->{error}} ) . "\n"; }
   print "connected: $result\n";
}



Re: QUESTION: POE Nomenclature

2007-03-01 Thread David Davis

POE is not threaded, and therefore multiple 'event chains' won't be running
simultaneously in a single process.

David

On 3/1/07, Michael Collins <[EMAIL PROTECTED]> wrote:


> i believe 'event chain' would be appropriate
>
> On 3/1/07, Michael Collins <[EMAIL PROTECTED]> wrote:
> >
> > POE Gang,
> >
> > I have a nomenclature question.  Let's say you have one or more POE
> > sessions.  When you have an 'event flow' - the flow of control moves
> > from session to session (or to different events within a session) -
I'm
> > wondering what you call it.  Is it a 'thread' or a 'threadoid'?
Just
> > curious what terminology you use.
> >
> > I'm working on a program that has several threads or 'event chains'
as I
> > call them.  I'm trying to document my program with intuitive terms
that
> > would make sense to someone familiar with POE.
> >
> > So, in the context of POE, do you call them 'threads' or is there a
> > better expression to be used?
> >
> > Thanks,
> > MC
> >

Thanks for the input.  I think 'event chains' describes what I'm talking
about pretty well.  At the very least it helps me to visualize mentally
what is happening inside a POE program where multiple 'event chains' all
could be working simultaneously.  I'll be sure to put the expression in
the glossary section of my docs.

-MC



Re: POE and XUL

2007-02-23 Thread David Davis

Whoops, forgot to cc the list.

David

-- Forwarded message --
From: David Davis <[EMAIL PROTECTED]>
Date: Feb 23, 2007 11:00 AM
Subject: Re: POE and XUL
To: Rutger Vos <[EMAIL PROTECTED]>

The problem with the xul poco is that you can't send data back to the
browser unless an action warrants it.  You click a button, it hits the
server and the data is sent back.  I hit this same wall when I wrote poco
xul.

What you really need is cometd.  http://cometd.com/   I'm the lead dev on
the project and I will have the perl / poe server working soon.  Perhaps
this weekend.  I want to integrate cometd with XUL too, so I'll let you know
when I have something.  Until then, feel free to join the mailing list for
cometd, located on the site.

Cheers!
David

On 2/23/07, Rutger Vos <[EMAIL PROTECTED]> wrote:


Dear POE programmers,

I am attempting to write a POE program that does two things:

1. construct and manage a POE::Component::XUL application;

2. follow a growing log file.

The idea is that the log file follower sends new lines in the log to the
XUL
application, to be displayed in a TextWindow XUL widget. As far as the XUL
app is concerned - I got that figured out: it shows up in the browser
window, and the buttons (etc.) do what I mean for them to do. Likewise,
the
log follower does what it's supposed to do, at least in so far as writing
changes to the log to STDOUT. What doesn't seem to work is for those same
changes to show up in the textwindow.

Now, although I am a reasonable programmer, I must admit to a bit of
voodoo
programming in regards to POE - I'm reading the wiki, and trying to get my
head around things, but it's a lot to take in. I assume things going wrong
in my efforts have got something to do with the XUL app and the log
follower
doing their thing in their own space, but the reference to the textwindow
that I pushed onto the HEAP when constructing the XUL app has the same
memory address (refaddr) as the one that the log follower pulls off the
heap
when executing the log following callbacks, and still it's not working.

I hope you don't mind me posting some code, to clarify:

###
# snipped preambles...

POE::Session->create(
'inline_states' => {
'_start' => sub {
my ( $kernel, $heap, $session ) = @_[KERNEL, HEAP, SESSION];

# build XUL app
POE::Component::XUL->spawn( {
'port' => $PORT, # from @ARGV
'root' => $ROOT, # from @ARGV
'apps' => {
'Regman' => sub { # Regman = Registry Manager

# widget construction happens here
XUL::Node::Application::Regman->VERBOSE( $VERBOSE
);
my $regman = XUL::Node::Application::Regman->_new;


# push logwindow onto heap
$heap->{'_logwindow'} = $regman->{'_logwindow'};

# return main window, this works, shows in firefox

return $regman->_main;
}
},
} );

# the following is a blatant c&p from the wiki
$_[HEAP]->{'wheel'} = POE::Wheel::FollowTail->new(
'Filename'   => $LOGFILE, # from @ARGV
'InputEvent' => 'got_line',
'ErrorEvent' => 'got_error',
'SeekBack'   => 1024,
);
$_[HEAP]->{'first'} = 0;
},
'got_line' => sub {

# this is the same logwindow as when the xul app was
constructed
my $logwindow = $_[HEAP]->{'_logwindow'};
if ( $_[HEAP]->{'first'}++ && defined $logwindow ) {

# these messages show up when the log changes
print "MESSAGE FROM LOGWATCHER: " . $_[ARG0] . "\n";

# attempt to send msg to xul widget
$logwindow->value( $_[ARG0] );

# sure enough, the widget is modified, but not in firefox?
# i.e. ->value() has changed, but the actual text widget
# shows nothing?
print "LISTENING TO LOGWINDOW: " . $logwindow->value() .
"\n";
}
elsif ( $_[HEAP]->{'first'}++ && ! defined $logwindow ) {
print "MESSAGE FROM LOGWATCHER: " . $_[ARG0] . "\n";
}
},
'got_error' => sub {
my $logwindow = $_[HEAP]->{'_logwindow'};
if ( $_[HEAP]->{'first'}++ &

Re: EasyDBI -- No result, just 'Died' [Was: POE & DBI]

2007-02-22 Thread David Davis

Since I don't have a test case, You'll have to dig deeper yourself.

David

On 2/22/07, Jake Peavy <[EMAIL PROTECTED]> wrote:


Forgot the list... sorry.

-jp

-- Forwarded message --
From: Jake Peavy <[EMAIL PROTECTED]>
Date: Feb 21, 2007 6:09 PM
Subject: Re: EasyDBI -- No result, just 'Died' [Was: POE & DBI]
To: David Davis <[EMAIL PROTECTED]>

I'm not totally sure what you mean by "error message"...

With
  sub POE::Component::EasyDBI::DEBUG () { 1 }

I get the following:

  $_[ARG0]->{'error'} => 'Died'

and

  POE::Component::EasyDBI got an read error 0 from Subprocess: ''
shutdown:
1

Does that help?

-jp



On 2/21/07, David Davis < [EMAIL PROTECTED]> wrote:
>
> Do you have the exact error message handy?  None of my code has the word
> died, so I'm assuming its an error coming from dbi or dbd::odbc
>
> David
>
> On 2/21/07, Jake Peavy <[EMAIL PROTECTED]> wrote:
> >
> > On 2/21/07, David Davis <[EMAIL PROTECTED]> wrote:
> > >
> > > I'm the author of EasyDBI
> >
> >
> > 
> >
> > Comments? Suggestions?
> > >
> > > David
> > >
> > > On 2/21/07, Matt Sickler <[EMAIL PROTECTED]> wrote:
> > > >
> > > > yes, DBI  and PoCoEasyDBI work just fine on windows
> > > >
> > > > On 2/21/07, Bill Nash <[EMAIL PROTECTED]> wrote:
> > > > >
> > > > >
> > > > > Well...
> > > > >
> > > > > A better question would be: Do Perl and DBI work with windows?
> > > > >
> > > > > - billn
> > > > >
> > > > > On Wed, 21 Feb 2007, Mathieu Longtin wrote:
> > > > >
> > > > > > Do any of them work with windows?
> > > > > >
> > > > > > On 2/21/07, Matt Sickler <[EMAIL PROTECTED]> wrote:
> > > > > > >
> > > > > > > POE::Component::EasyDBI is what I use - quite simple and can
> > be
> > > > > powerful
> > > > > > >
> > > > > > > On 2/20/07, Kevin Scaldeferri < [EMAIL PROTECTED]>
wrote:
> > > > > > > >
> > > > > > > > Anyone want to strongly advocate for one of the four or so
> > > > > components
> > > > > > > > that comes up on a CPAN search for "POE DBI"?
> > >
> >
> > Ah, the perfect thread for me to jump in with an issue I had with
> > EasyDBI on
> > Win32, original message below to which I received no responses.  Any
> > advice
> > would be much appreciated.
> >
> > -- Forwarded message --
> > From: Jake Peavy <[EMAIL PROTECTED]>
> > Date: Dec 6, 2006 7:09 PM
> > Subject: EasyDBI -- No result, just 'Died'
> > To: POE Mailing List < poe@perl.org>
> >
> > Hey yall,
> >
> > I'm having some problems with EasyDBI.  I'm trying to do two
> > simultaneous
> > selects from two different databases.  Both queries work fine via
> > standard
> > DBI, but when I run through EasyDBI and POE, the queries take the
right
> > amount of time (the query time is roughly 2 minutes), but they don't
> > return
> > results - all I get is the Error value of the hash in ARG0 reporting
the
> > query "Died".
> >
> > The queries make use of DBD::ODBC if that matters.  My guess is maybe
> > that
> > EasyDBI sees something in the return value that it interprets as the
> > query
> > dying (maybe it's trying to compare the number of rows it got to the
> > number
> > the DB reported it was sending?  just a WAG..), however, like I said,
> > the
> > queries are ok using a normal DBI connection.
> >
> > Here's the code I'm using though it won't be much help without the
back
> > end
> > DB.  If anyone has any ideas on how to debug, I'm all ears.  In the
> > meantime, I also tried SimpleDBI, stay tuned for those results... :)~
> >
> > TIA,
> > -jp
> >
> > #!/usr/bin/perl
> >
> > use strict;
> > use warnings;
> >
> > use POE;
> > use POE::Component::EasyDBI;
> >
> > use Data::Dumper;
> > $Data::Dumper::Maxdepth = 1;
> >
> > POE::Component::EasyDBI->spawn(
> > alias   => 'db1',
> > dsn => 'dbi:ODBC:Sybase.db1',
> > username=> 'user',
> > p

Re: EasyDBI -- No result, just 'Died' [Was: POE & DBI]

2007-02-21 Thread David Davis

Do you have the exact error message handy?  None of my code has the word
died, so I'm assuming its an error coming from dbi or dbd::odbc

David

On 2/21/07, Jake Peavy <[EMAIL PROTECTED]> wrote:


On 2/21/07, David Davis <[EMAIL PROTECTED]> wrote:
>
> I'm the author of EasyDBI




Comments? Suggestions?
>
> David
>
> On 2/21/07, Matt Sickler <[EMAIL PROTECTED]> wrote:
> >
> > yes, DBI  and PoCoEasyDBI work just fine on windows
> >
> > On 2/21/07, Bill Nash <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > > Well...
> > >
> > > A better question would be: Do Perl and DBI work with windows?
> > >
> > > - billn
> > >
> > > On Wed, 21 Feb 2007, Mathieu Longtin wrote:
> > >
> > > > Do any of them work with windows?
> > > >
> > > > On 2/21/07, Matt Sickler <[EMAIL PROTECTED]> wrote:
> > > > >
> > > > > POE::Component::EasyDBI is what I use - quite simple and can be
> > > powerful
> > > > >
> > > > > On 2/20/07, Kevin Scaldeferri <[EMAIL PROTECTED]> wrote:
> > > > > >
> > > > > > Anyone want to strongly advocate for one of the four or so
> > > components
> > > > > > that comes up on a CPAN search for "POE DBI"?
>

Ah, the perfect thread for me to jump in with an issue I had with EasyDBI
on
Win32, original message below to which I received no responses.  Any
advice
would be much appreciated.

-- Forwarded message --
From: Jake Peavy <[EMAIL PROTECTED]>
Date: Dec 6, 2006 7:09 PM
Subject: EasyDBI -- No result, just 'Died'
To: POE Mailing List 

Hey yall,

I'm having some problems with EasyDBI.  I'm trying to do two simultaneous
selects from two different databases.  Both queries work fine via standard
DBI, but when I run through EasyDBI and POE, the queries take the right
amount of time (the query time is roughly 2 minutes), but they don't
return
results - all I get is the Error value of the hash in ARG0 reporting the
query "Died".

The queries make use of DBD::ODBC if that matters.  My guess is maybe that
EasyDBI sees something in the return value that it interprets as the query
dying (maybe it's trying to compare the number of rows it got to the
number
the DB reported it was sending?  just a WAG..), however, like I said, the
queries are ok using a normal DBI connection.

Here's the code I'm using though it won't be much help without the back
end
DB.  If anyone has any ideas on how to debug, I'm all ears.  In the
meantime, I also tried SimpleDBI, stay tuned for those results... :)~

TIA,
-jp

#!/usr/bin/perl

use strict;
use warnings;

use POE;
use POE::Component::EasyDBI;

use Data::Dumper;
$Data::Dumper::Maxdepth = 1;

POE::Component::EasyDBI->spawn(
alias   => 'db1',
dsn => 'dbi:ODBC:Sybase.db1',
username=> 'user',
password=> 'pass',
stopwatch   => 1,
);

POE::Component::EasyDBI->spawn(
alias   => 'db2',
dsn => 'dbi:ODBC:Sybase.db2',
username=> 'user',
password=> 'pass',
stopwatch   => 1,
);

POE::Session->create(
inline_states => {

_start => sub {
print '[' . localtime() . "] initiating db1 query\n";
$_[KERNEL]->post( 'db1',
arrayhash => {
  sql  => 'select * from table where foo = ?',
  event=> 'db1_result_handler',
  placeholders => [ 'bar' ],
}
);

print '[' . localtime() . "] initiating db2 query\n";
$_[KERNEL]->post( 'db2',
arrayhash => {
  sql  => 'select * from table where foo = ?',
  event=> 'db2_result_handler',
  placeholders => [ 'bar' ],
}
);
},

db1_result_handler => sub {
#my %success_hash = %{ $_[ARG0] };

print '[' . localtime() . "] db1 query complete\n";
print Dumper $_[ARG0];
$_[KERNEL]->post( db1 => 'shutdown' );
},

db2_result_handler => sub {
#my %success_hash = %{ $_[ARG0] };

print '[' . localtime() . "] db2 query complete\n";
print Dumper $_[ARG0];
$_[KERNEL]->post( db2 => 'shutdown' );
},

},
);

$poe_kernel->run();

__END__

--
-jp


Chuck Norris sleeps with a night light. Not because Chuck Norris is afraid
of the dark, but the dark is afraid of Chuck Norris



Re: POE & DBI

2007-02-21 Thread David Davis

I'm the author of EasyDBI and I just wanted to let everyone know that I'm
adding support for multiple forks and classes.

A hypothetical setup could be 5 connections, the first 4 being mysql slaves,
and the last a mysql master.

host #1 - class read
host #2 - class read
host #3 - class read
host #4 - class read
host #5 - class write

Your select queries with the class read would be distributed between the
first 4 hosts in the read class.  You would classify your updates with the
write class and they would be sent to host 5.

Comments? Suggestions?

David

On 2/21/07, Matt Sickler <[EMAIL PROTECTED]> wrote:


yes, DBI  and PoCoEasyDBI work just fine on windows

On 2/21/07, Bill Nash <[EMAIL PROTECTED]> wrote:
>
>
> Well...
>
> A better question would be: Do Perl and DBI work with windows?
>
> - billn
>
> On Wed, 21 Feb 2007, Mathieu Longtin wrote:
>
> > Do any of them work with windows?
> >
> > On 2/21/07, Matt Sickler <[EMAIL PROTECTED]> wrote:
> > >
> > > POE::Component::EasyDBI is what I use - quite simple and can be
> powerful
> > >
> > > On 2/20/07, Kevin Scaldeferri <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Anyone want to strongly advocate for one of the four or so
> components
> > > > that comes up on a CPAN search for "POE DBI"?
> > > >
> > > > -kevin
> > > >
> > >
> >
> >
> >
> >
>



Re: problems installing POE in linux host

2007-02-20 Thread David Davis

I don't know much about readline, but perhaps someone else could chime in.
That test runs fine here.  For now you can force install POE on the cpan
command line and start hacking.

David

On 2/20/07, Michael Hare <[EMAIL PROTECTED]> wrote:


Please see attached.  I haven't stepped through the test code at this
point to try to see where the error is.  It seems as if the POE module
works fine on the host in question although the test has failed.

-Michael

David Davis wrote:
> Could you run the test manually and reply with the output?
>
> If using CPAN.pm:
>
> perl -MCPAN -e shell
> cpan[4]> look POE
>
>
> perl Makefile.PL
> # prepare ./mylib
> make
> # edit the readline test, and change the 0 to 1 in sub DEBUG() { 0 }
> vim ./t/30_loops/00_base/wheel_readline.pm
> # then run the test
> perl ./t/30_loops/00_base/wheel_readline.pm
>
> Reply with the results
>
> Cheers!
> David
>
> On 2/20/07, Michael Hare <[EMAIL PROTECTED]> wrote:
>>
>> Hello-
>>
>> Trying to install POE on a linux host via CPAN; make test is hanging on
>> the the following test
>>
>> t/30_loops/10_select/wheel_acceptskipped
>> all skipped: Network access (and permission) required to run
>> this test
>> t/30_loops/10_select/wheel_cursesskipped
>> all skipped: Need help with Curses functions blocking under
ptys
>> t/30_loops/10_select/wheel_readline..ok 1/6 <
>>
>> What information could I provide to be helpful to try to figure out
this
>> problem?
>>
>> -Michael
>>
>

cpan> look POE
CPAN: Storable loaded ok
Going to read /home/root/.cpan/Metadata
  Database was generated on Tue, 20 Feb 2007 14:09:29 GMT
Running look for module POE

Trying to open a subshell in the build directory...
CPAN: Digest::MD5 loaded ok
CPAN: Compress::Zlib loaded ok
Checksum for /home/root/.cpan/sources/authors/id/R/RC/RCAPUTO/POE-
0.9917.tar.gz ok
Scanning cache /home/root/.cpan/build for sizes
POE-0.9917/
POE-0.9917/CHANGES
POE-0.9917/examples/
POE-0.9917/examples/create.perl
POE-0.9917/examples/fakelogin.perl
POE-0.9917/examples/forkbomb.perl
POE-0.9917/examples/names.perl
POE-0.9917/examples/objmaps.perl
POE-0.9917/examples/objsessions.perl
POE-0.9917/examples/packagesessions.perl
POE-0.9917/examples/queue.perl
POE-0.9917/examples/README.samples
POE-0.9917/examples/selects.perl
POE-0.9917/examples/sessions.perl
POE-0.9917/examples/signals.perl
POE-0.9917/examples/tcp_watermarks.perl
POE-0.9917/examples/thrash.perl
POE-0.9917/examples/watermarks.perl
POE-0.9917/examples/wheels2.perl
POE-0.9917/HISTORY
POE-0.9917/lib/
POE-0.9917/lib/POE/
POE-0.9917/lib/POE/API/
POE-0.9917/lib/POE/API/Ctl.pm
POE-0.9917/lib/POE/API/ResLoader.pm
POE-0.9917/lib/POE/Component/
POE-0.9917/lib/POE/Component/Client/
POE-0.9917/lib/POE/Component/Client/TCP.pm
POE-0.9917/lib/POE/Component/Server/
POE-0.9917/lib/POE/Component/Server/TCP.pm
POE-0.9917/lib/POE/Component.pm
POE-0.9917/lib/POE/Driver/
POE-0.9917/lib/POE/Driver/SysRW.pm
POE-0.9917/lib/POE/Driver.pm
POE-0.9917/lib/POE/Filter/
POE-0.9917/lib/POE/Filter/Block.pm
POE-0.9917/lib/POE/Filter/Grep.pm
POE-0.9917/lib/POE/Filter/HTTPD.pm
POE-0.9917/lib/POE/Filter/Line.pm
POE-0.9917/lib/POE/Filter/Map.pm
POE-0.9917/lib/POE/Filter/RecordBlock.pm
POE-0.9917/lib/POE/Filter/Reference.pm
POE-0.9917/lib/POE/Filter/Stackable.pm
POE-0.9917/lib/POE/Filter/Stream.pm
POE-0.9917/lib/POE/Filter.pm
POE-0.9917/lib/POE/Kernel.pm
POE-0.9917/lib/POE/Loop/
POE-0.9917/lib/POE/Loop/Event.pm
POE-0.9917/lib/POE/Loop/Gtk.pm
POE-0.9917/lib/POE/Loop/IO_Poll.pm
POE-0.9917/lib/POE/Loop/PerlSignals.pm
POE-0.9917/lib/POE/Loop/Select.pm
POE-0.9917/lib/POE/Loop/Tk.pm
POE-0.9917/lib/POE/Loop/TkActiveState.pm
POE-0.9917/lib/POE/Loop/TkCommon.pm
POE-0.9917/lib/POE/Loop.pm
POE-0.9917/lib/POE/NFA.pm
POE-0.9917/lib/POE/Pipe/
POE-0.9917/lib/POE/Pipe/OneWay.pm
POE-0.9917/lib/POE/Pipe/TwoWay.pm
POE-0.9917/lib/POE/Pipe.pm
POE-0.9917/lib/POE/Queue/
POE-0.9917/lib/POE/Queue/Array.pm
POE-0.9917/lib/POE/Queue.pm
POE-0.9917/lib/POE/Resource/
POE-0.9917/lib/POE/Resource/Aliases.pm
POE-0.9917/lib/POE/Resource/Controls.pm
POE-0.9917/lib/POE/Resource/Events.pm
POE-0.9917/lib/POE/Resource/Extrefs.pm
POE-0.9917/lib/POE/Resource/FileHandles.pm
POE-0.9917/lib/POE/Resource/Sessions.pm
POE-0.9917/lib/POE/Resource/SIDs.pm
POE-0.9917/lib/POE/Resource/Signals.pm
POE-0.9917/lib/POE/Resource/Statistics.pm
POE-0.9917/lib/POE/Resource.pm
POE-0.9917/lib/POE/Resources.pm
POE-0.9917/lib/POE/Session.pm
POE-0.9917/lib/POE/Wheel/
POE-0.9917/lib/POE/Wheel/Curses.pm
POE-0.9917/lib/POE/Wheel/FollowTail.pm
POE-0.9917/lib/POE/Wheel/ListenAccept.pm
POE-0.9917/lib/POE/Wheel/ReadLine.pm
POE-0.9917/lib/POE/Wheel/ReadWrite.pm
POE-0.9917/lib/POE/Wheel/Run.pm
POE-0.9917/lib/POE/Wheel/SocketFactory.pm
POE-0.9917/lib/POE/Wheel.pm
POE-0.9917/lib/POE.pm
POE-0.9917/Make

Re: problems installing POE in linux host

2007-02-20 Thread David Davis

Could you run the test manually and reply with the output?

If using CPAN.pm:

perl -MCPAN -e shell
cpan[4]> look POE


perl Makefile.PL
# prepare ./mylib
make
# edit the readline test, and change the 0 to 1 in sub DEBUG() { 0 }
vim ./t/30_loops/00_base/wheel_readline.pm
# then run the test
perl ./t/30_loops/00_base/wheel_readline.pm

Reply with the results

Cheers!
David

On 2/20/07, Michael Hare <[EMAIL PROTECTED]> wrote:


Hello-

Trying to install POE on a linux host via CPAN; make test is hanging on
the the following test

t/30_loops/10_select/wheel_acceptskipped
all skipped: Network access (and permission) required to run
this test
t/30_loops/10_select/wheel_cursesskipped
all skipped: Need help with Curses functions blocking under ptys
t/30_loops/10_select/wheel_readline..ok 1/6 <

What information could I provide to be helpful to try to figure out this
problem?

-Michael



Re: another ::ReadLine question (possibly a bug)

2007-02-13 Thread David Davis

Although it doesn't cause errors, it does truncate the number of printed
lines.  37/50 or 128/200

David

On 2/13/07, David Davis <[EMAIL PROTECTED]> wrote:


It doesn't blow up on me when I run it and type /go 200.

POE .95
Perl v5.8.7

I even upgraded to POE v.9917, and it still worked.

David

On 13 Feb 2007 09:37:38 -0800, Paul Miller <[EMAIL PROTECTED]> wrote:
>
>
>
> I'm including an entire sample program that looks like a great deal
> more than it is...  It's just a simple shell that supports three
> commands:  /quit, /go and /np.
>
> If you run this and issue a /np; possibly even a /np 200, you'll see
> 50 or 200 lines of randomly generated text.  Boring.
>
> However, if you were to run /go 200 you would see the Wheel crash
> horribly.  It will still technically function, but in a miserable sort
> of way -- and even though it still sortof works, the output will be
> truncated.  I have spent a few hours trying to figure out why, but I
> haven't put my finger on it.
>
> In any case, it seems to me that a POE Wheel should survive put()
> events while readline is already get()ing
>
> -Paul
>
>
>
>
>
> use strict;
> use POE qw(Wheel::ReadLine);
>
> my $rls = POE::Session->create( package_states => [
> main=>[qw(_start input spam)]
> ]);
>
> sub garbage {
> my $garbage = "";
>$garbage .= chr( (ord ' ') + (int rand 36) ) for 1 .. 80;
>
> return $garbage;
> }
>
> sub input {
> my ($heap, $kern, $input, $exception) = @_[HEAP, KERNEL, ARG0,
> ARG1];
> my $rl = $heap->{wheel};
>
> if( defined $input ) {
> $rl->addhistory($input);
>
> if( $input =~ m/^\s*\/?(?:quit|exit)/ ) {
> exit;
>
> } elsif( $input =~ m/^\s*\/(?:go|spam)\s*(\d*)/ ) {
> $kern->delay( spam => 2, ($1||50) )
>
> } elsif( $input =~ m/^\s*\/(?:np|npspam)\s*(\d*)/ ) {
> $rl->put("** np spam: " . &garbage) for 1 .. ($1||50);
>
> } else {
> $rl->put("** heard: $input");
> }
>
> } else {
> $rl->put("** unknown exception: $exception");
> }
>
> $rl->get("test> ");
> }
>
> sub _start {
> my $heap = $_[HEAP];
>
> $heap->{wheel} = new POE::Wheel::ReadLine( InputEvent =>
> 'input' );
> $heap->{wheel}->get("test> ");
> }
>
> sub _stop {
> delete $_[HEAP]->{wheel};
> }
>
> sub spam {
> my $rl = $_[HEAP]->{wheel};
> my $n  = $_[ARG0];
>
> $rl->put("** spam ($_/$n): " . &garbage) for 1 .. $n;
> }
>
> run POE::Kernel;
> exit;
>
>



Re: another ::ReadLine question (possibly a bug)

2007-02-13 Thread David Davis

It doesn't blow up on me when I run it and type /go 200.

POE .95
Perl v5.8.7

I even upgraded to POE v.9917, and it still worked.

David

On 13 Feb 2007 09:37:38 -0800, Paul Miller <[EMAIL PROTECTED]> wrote:




I'm including an entire sample program that looks like a great deal
more than it is...  It's just a simple shell that supports three
commands:  /quit, /go and /np.

If you run this and issue a /np; possibly even a /np 200, you'll see
50 or 200 lines of randomly generated text.  Boring.

However, if you were to run /go 200 you would see the Wheel crash
horribly.  It will still technically function, but in a miserable sort
of way -- and even though it still sortof works, the output will be
truncated.  I have spent a few hours trying to figure out why, but I
haven't put my finger on it.

In any case, it seems to me that a POE Wheel should survive put()
events while readline is already get()ing

-Paul





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

my $rls = POE::Session->create( package_states => [
main=>[qw(_start input spam)]
]);

sub garbage {
my $garbage = "";
   $garbage .= chr( (ord ' ') + (int rand 36) ) for 1 .. 80;

return $garbage;
}

sub input {
my ($heap, $kern, $input, $exception) = @_[HEAP, KERNEL, ARG0,
ARG1];
my $rl = $heap->{wheel};

if( defined $input ) {
$rl->addhistory($input);

if( $input =~ m/^\s*\/?(?:quit|exit)/ ) {
exit;

} elsif( $input =~ m/^\s*\/(?:go|spam)\s*(\d*)/ ) {
$kern->delay( spam => 2, ($1||50) )

} elsif( $input =~ m/^\s*\/(?:np|npspam)\s*(\d*)/ ) {
$rl->put("** np spam: " . &garbage) for 1 .. ($1||50);

} else {
$rl->put("** heard: $input");
}

} else {
$rl->put("** unknown exception: $exception");
}

$rl->get("test> ");
}

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

$heap->{wheel} = new POE::Wheel::ReadLine( InputEvent =>
'input' );
$heap->{wheel}->get("test> ");
}

sub _stop {
delete $_[HEAP]->{wheel};
}

sub spam {
my $rl = $_[HEAP]->{wheel};
my $n  = $_[ARG0];

$rl->put("** spam ($_/$n): " . &garbage) for 1 .. $n;
}

run POE::Kernel;
exit;




Re: POE::Wheel::ReadLine change_prompt

2007-02-06 Thread David Davis

Did $heap->{wheel}->get( "prompt:" ); not work for you?

It's documented.

David


On 5 Feb 2007 13:35:13 -0800, Paul Miller <[EMAIL PROTECTED]> wrote:


I'm using POE::Wheel::Run successfully and there's a situation where
my prompt should change dynamically.  I couldn't find a way to do it
directly, but using the source I created this mess:

sub change_prompt {
my $heap = $_[HEAP];
my $arg0 = $_[ARG0];

EVIL_HACK: {
local $| = 1; print "\r", " " x (length $heap->{prompt}),
"\r";

$heap->{prompt} = $arg0;
$heap->{wheel}->[ $heap->{wheel}->SELF_PROMPT ] = $arg0;
$heap->{wheel}->_repaint_input_line;
}
}

First of all, is there a better, less internally hacky way to do
this?  Second, if not, given that it seems like such a natural thing
to want to do; why isn't it already in there somewhere?




Re: when working with files under POE, shouldn't IO::AIO be used?

2006-12-13 Thread David Davis

Here is my working example:

http://svn.xantus.org/shortbus/trunk/cometd-perl/lab/aio.pl

David


On 12/13/06, Rocco Caputo <[EMAIL PROTECTED]> wrote:


Although Marc Lehmann doesn't come out and say so, IO::AIO provides
two features that support its use from POE in a couple different ways.

It exposes a file descriptor, which can be used to notify select-like
loops when AIO operations are complete.  For example:

   # POE integration
   open my $fh, "<&=" . IO::AIO::poll_fileno or die "$!";
   $_[KERNEL]->select_read($fh, "aio_event");

Or you can use its callback mechanism with POE::Session's postback()
or callback():

   aio_open "/etc/passwd", O_RDONLY, 0, $_[SESSION]->postback
("aio_open_event");


Whether you "should" use IO::AIO is a matter of your application's

requirements.  Quite a lot of systems don't require AIO, so they
shouldn't use IO::AIO.

I hope this helps.

--
Rocco Caputo - [EMAIL PROTECTED]

On Dec 11, 2006, at 04:42, [EMAIL PROTECTED] wrote:

> According to the documentation that only does buffered I/O. There are
> many other file operations that can block, which IO::AIO deals with-
> file opening and creation, closing and deletion, link/symlink, stat,
> rename, etc.  Does POE handle those as well?
>
> Matt Sickler wrote:
>> why use IO::AIO when there is POE::Wheel::ReadWrite?
>>
>> On 9 Dec 2006 21:37:14 -0800, [EMAIL PROTECTED]
>> <[EMAIL PROTECTED]>
>> wrote:
>>>
>>> To avoid blocking when doing file operations under POE, shouldn't
>>> IO::AIO be used? I haven't seen any mention or examples of two being
>>> used together.  If somebody has done this already, can they post an
>>> example here or on the wiki. Thanks.
>>>
>>> Also, there was a brief mention [1] on the djabberd mailing list
>>> that
>>> Brad would like to bring Danga::Socket and POE together. Any
>>> thoughts
>>> from this camp?
>>>
>>> [1] http://lists.danga.com/pipermail/djabberd/2006-October/
>>> 000198.html
>>>
>>>
>>
>> --=_Part_72409_23861310.1165808259206--





Re: POE::Wheel::ReadWrite performance

2006-07-06 Thread David Davis

Have you tried usiing POE::Loop::Epoll?

David

On 7/5/06, Michael Giambalvo <[EMAIL PROTECTED]> wrote:


I'm working on a large scale TCP server application.

Based on profiling, I see that more than half the CPU time of my
server session is spent either in POE::Wheel::ReadWrite->read or
POE::Wheel::ReadWrite->write.

Any suggestions on eliminating this bottleneck?  My session is
currently implemented using POE::Component::Client::TCP.   I guess I
could implement my session in C, but I'm not sure how I'd do it in a
way that avoids the same overhead the POE::Wheel::ReadWrite suffers
from.

Anyone have experience with implemented high volume clients with POE?



Re: XMLRPC server problem (Perl 5.8)

2006-06-27 Thread David Davis

This is exceptions related.
http://search.cpan.org/~rcaputo/POE-0.3502/lib/POE/Kernel.pm#Signal_Watcher_Methods

An error in your _stop is causing an exception, POE delivers a signal,
notices it needs to stop your session and calls _stop, then an error occurs,
and you get the idea.

HTH
David

On 6/23/06, Bob Maccione <[EMAIL PROTECTED]> wrote:


Hi all,

I'm running on linux with perl 5.8.8,  poe 0.3501 and component...XMLRPC
0.05.

If I have a runtime error in my code, POE goes into a loop (recursion it
appears) where it eats up all the memory on the box and with logging
enabled it generates the following line again and again..

 stopping session 5 (POE::Session=ARRAY(0x9ff1cd0)) at
/hilton/lib/perl5/site_perl/5.8.8/POE/Resource/Sessions.pm line 4575 ->
_stop (from hilton/lib/perl5/site_perl/5.8.8/POE/Resource/Sessions.pm at
484)
 stopping session 5 (POE::Session=ARRAY(0x9ff1cd0)) at
/hilton/lib/perl5/site_perl/5.8.8/POE/Resource/Sessions.pm line 4575 ->
_stop (from hilton/lib/perl5/site_perl/5.8.8/POE/Resource/Sessions.pm at
484)


I have the following test code that can reproduce it,  can anyone
confirm if it's a perl 5.8 or poe problem?  We just moved to 5.8 and the
latest POE (it's a new box and we wanted to start from scratch).  It
doesn't appear to happen on some real old poe and perl 5.6.

there are 2 files,  Foo and FooTst,  run the Foo as nohup Foo & and then
the FooTst will cause the problem.

thanks for any help,
bob maccione



---
#!/usr/bin/perl -w -I .

use strict;

sub POE::Kernel::ASSERT_DEFAULT () { 1 }
sub POE::Kernel::TRACE_SESSIONS  () { 1 }
use POE;
use POE::Component::Server::XMLRPC;

#
# load up context and enable the Debug/Logging, etc.
#
Init();

Main();



=item Init()

Do the one time stuff here..

=cut
sub Init {

  Startup( 9191 );

}

=item Main()

Do the fancy main processing here..

=cut
sub Main {

  $poe_kernel->run;
  exit 0;

}


=item Startup()

This is called once from the main Init routine and is used to get the
ball rolli
ng.

input:
port - the port to listen on

returns:
nothin

=cut
sub Startup {
  my $port = shift;

  print STDERR "Startup: port $port\n";

  POE::Component::Server::XMLRPC->new( alias => "xmlrpc", port  => 'dev'
);

  POE::Session->create
   ( inline_states =>
 { _start => \&SetupService,
   _stop  => \&ShutdownService,


   # our stuff..
   Test => \&Test,
 },

  options => { trace => 1, debug => 1 },
   );

  #
  # we're done in the init stage for now

}

=item SetupService()

Start the listening service.  You need to add a post for each txn you'll
want to support

=cut
sub SetupService {
  my $kernel = $_[KERNEL];
  print STDERR "SetupService\n";

  # set all of the services
  $kernel->post( xmlrpc => publish => dev => "Test" );

  print STDERR "SetupService Done\n";

}

=item ShutDownService()

Stop the xmlrpc service

=cut
sub ShutDownService {
  print STDERR "ShutdownService\n";

  # unset all of the services
  $_[KERNEL]->post( xmlrpc => rescind => dev => "Ngt" );
  $_[KERNEL]->post( xmlrpc => rescind => dev => "Ping" );
  $_[KERNEL]->post( xmlrpc => rescind => dev => "Search" );
  $_[KERNEL]->post( xmlrpc => rescind => dev => "Test" );

  print STDERR "ShutdownService Done\n";
}


=item Test()

Simple Test txn

=cut
sub Test {
  my $transaction = $_[ARG0];
  my $params = $transaction->params();
  print STDERR "Running test routine\n";

  $params->Foo();

  $transaction->return( "Pong" );
}


---

this is the test code



---
#!/usr/bin/perl -w

# send in a ping txn to the listener
use strict;
use Debug;
use Data::Dumper;

use XMLRPC::Lite;

my $name = 'http://localhost:9191/xmlrpc';

my $txn = 'Ping';

print XMLRPC::Lite
-> proxy('http://localhost:9191/?session=dev')
-> Test()
-> result
;


---






Re: installation problems of POE 0.35

2006-05-23 Thread David Davis

Gil,

I've fixed that test in svn.  You can either check out the lastest version
or force install POE.

David

On 5/23/06, Gil Vidals <[EMAIL PROTECTED]> wrote:


My upgrade to POE 0.35 failed. I've installed POE several times and
never had a problem before. I install via CPAN's "install POE".

The strange thing is that the intall fails on 9 of 8 tests instead of 8
of 9 tests. Can someone show me how to get around this error?

Thanks.

tests/30_loops/10_select/wheel_run...ok 9/8Don't know which
tests failed: got 9 ok, expected 8
tests/30_loops/10_select/wheel_sf_ipv6...skipped
all skipped: Socket6 is needed for IPv6 tests
tests/30_loops/10_select/wheel_sf_tcpok
tests/30_loops/10_select/wheel_sf_udpok
tests/30_loops/10_select/wheel_sf_unix...ok
tests/30_loops/10_select/wheel_tail..ok
tests/30_loops/20_poll/all_errorsskipped
all skipped: no reason given
tests/30_loops/20_poll/comp_tcp..ok
tests/30_loops/20_poll/comp_tcp_concurrent...# You might see a
'disconnect' error during this test.
# It may be ignored.
tests/30_loops/20_poll/comp_tcp_concurrent...ok
tests/30_loops/20_poll/k_alarms..ok
tests/30_loops/20_poll/k_aliases.ok
tests/30_loops/20_poll/k_detach..ok
tests/30_loops/20_poll/k_selects.ok
tests/30_loops/20_poll/k_signals.ok 2/8# Waiting 2
seconds for child processes to settle.
tests/30_loops/20_poll/k_signals.ok
tests/30_loops/20_poll/ses_nfa...ok
tests/30_loops/20_poll/ses_session...ok
tests/30_loops/20_poll/wheel_accept..ok
tests/30_loops/20_poll/wheel_run.ok 9/8Don't know which
tests failed: got 9 ok, expected 8



Failed Test   Stat Wstat Total Fail  Failed  List
of Failed

---
tests/30_loops/10_select/wheel_ru8   ??   %  ??
tests/30_loops/20_poll/wheel_run.8   ??   %  ??
60 tests and 17 subtests skipped.
Failed 2/141 test scripts, 98.58% okay. -2/3385 subtests failed, 100.06%okay.
make: *** [test_dynamic] Error 255
  /usr/bin/make test -- NOT OK
Running make install
  make test had returned bad status, won't install without force
Failed during this command:
  RCAPUTO/POE-0.35.tar.gz  : make_test NO


--
[EMAIL PROTECTED]
Position Research, Inc.
Search engine results by research
tel: (760) 480-8291 fax: (760) 480-8271
www.PositionResearch.com



Re: restoring signal handlers

2006-05-22 Thread David Davis

You could move the use POE line above the two use sigtrap lines.

David

On 22 May 2006 14:07:57 -0700, sbk <[EMAIL PROTECTED]> wrote:


hi,

i'm realizing that loading POE replaces my signal handlers

is there a way around this?  i rather like my signal handlers ... :)
they perform useful chores, like clean up shared memory segments.  of
course, i rather like POE, too ... it does useful things for me ...
naturally, i want both!

--sk

stuart kendrick
fhcrc


guru% cat test
#!/opt/vdops/bin/perl
use strict;
use warnings;
use sigtrap 'handler' => \&shut_down, 'normal-signals';
use sigtrap 'handler' => \&shut_down, 'error-signals';
use POE;

while (1) {
  sleep 60;
}

sub shut_down {
  die "yay!";
}
guru%./test
[hit Ctrl-C here]
guru%

whereas if i remove the 'use POE;' line, i see the following:

guru%./test
yay! at ./test line 13.
guru%




Re: Google Summer of Code

2006-05-01 Thread David Davis

*cough*bittorrent*cough*

Too bad they're BT shy.

David

On 5/1/06, Rocco Caputo <[EMAIL PROTECTED]> wrote:


Hi.  I've been invited to be a mentor for this year's Google Summer
of Code, and fool that I am I said yes. :)

I'd prefer to mentor a POE-related project, which means that some
student needs to propose one.  You can help this happen!

If you're an eligible student, and you'd like to be paid to have me
help you hack on something to do with POE, head over to http://
www.perl.org/advocacy/summerofcode/ and start reading.  Enrollment
started today.

If you have a great idea or an open-source project that needs a
couple months of tender lovin' care, suggest it here or post it to
POE's wiki ().  I'm totally drawing a
blank today, and the enrollment clock is running.

Thanks!

--
Rocco Caputo - [EMAIL PROTECTED]



Re: POE message not sent or received

2006-02-21 Thread David Davis
Lanas,

The alias bambi is on the server component NOT the sessions it spawns for
each connection.  InlineStates don't apply to the main server session but
the child sessions that are created.  So your post is going to the server
component, not the child session.  This makes sense to me.  I suggest if you
want to send a message to a connected clients, then store the session id on
connect (and delete it on disconnect), and use a function to post to each
session id.

David

On 2/21/06, lanas <[EMAIL PROTECTED]> wrote:
>
> On Tue, 21 Feb 2006 11:33:39 -0500
> Rocco Caputo <[EMAIL PROTECTED]> wrote:
>
> > > Why is this so ?  Isn't the alias for TCPServ 'bambi' and isn't it
> > > registered ?
>
> > "bambi" is the alias of the server itself, not that of a particular
> > connection.  Each session runs in a separate POE::Session, so each
> > is a different post() destination.  They are not given aliases by
> > default, but you can register them on connection and remove them
> > upon disconnect, similar to the way
> > http://poe.perl.org/?POE_Cookbook/ Chat_Server does it.
>
> Yes, I'm already using this mechanism.  But it relies on a TCP
> connection to register the sender's ID.  I'm concerned with POE
> messages, not the TCP stuff.  I got the following together to
> demonstrate this.  It's just me, and most likely there's something I
> did not grokked so far, but I find there's an inconsistency in the
> alias interface.
>
> Here goes.
>
> The basic idea is that 'Alias =>' works only for the TCP Client and not
> the Server.
>
> So there's a Server that will receive a TCP message from 'outside'.
> When it receives it, it uses $_[KERNEL]->post to send a POE message to
> 'bambi' :
>
> POE::Component::Server::TCP->new
>   (
>ClientInput => sub {
>  $_[KERNEL]->post("bambi", "sendRequest", $_[ARG0]);
>},
>
> Now, if I create another module with a simple Session bearing the
> 'bambi' alias, it gets received:
>
> POE::Session->create
>   (
>inline_states =>
>{
> _start => sub {$_[KERNEL]->alias_set('bambi')},
> sendRequest => sub {print "Got it !\n"},
>}
> );
>
> But if, instead of the Session above I use a Server::TCP component in
> the following way, it does not work:
>
> POE::Component::Server::TCP->new
>   (
> Alias => 'bambi',
> InlineStates =>
>{
>  sendRequest => sub {print "Got it !\n"},
>},
> )
>
> It works with TCP Client when the TCP Server below sends a POE message:
>
> POE::Component::Client::TCP->new
> (
>  Alias => 'lion',
>  InlineStates =>
>  {
>   msg => sub {
> print "  lion got: $_[ARG0]\n";
>   }
>  }
>)
>
>
> POE::Component::Server::TCP->new
>   (
>Alias => 'bambi',
>ClientInput => sub {
>  $_[KERNEL]->post("lion", "msg", $_[ARG0]);
>},
>
> But the other way, the Client sending a POE message to the Server,
> does not work unless the Client's ID is used like this (i.e. the chat
> server method) :
>
> # That's the client registering the Server's ID after the server
> # has sent a POE message:
>
> InlineStates =>
> {
> msg => sub {
>$_[HEAP]->{scomms} = $_[SENDER]->ID;
> }
> }
>
> # So when the Client receives data from ANOTHER server, it can
> # send a POE message to the 'bambi' Server using the ID it has
> # saved previously:
>
> ServerInput => sub {
>$_[KERNEL]->post($_[HEAP]->{scomms} => FWreply => $_[ARG0]);
> }
>
>
> It is not possible to simply use the 'bambi' alias defined by the
> Server itself.  But it's possible for the Server to use the alias
> 'lion' defined by the Client.  So far, I find this is a bit
> inconsistent.  Why should the 'Alias => ' work with the client
> and not with the Server ?  Would this be caused by launching all
> modules from a main file and some data initialized prematurely ?
>
>


Re: Getting "POE::Kernel's run() method was never called" when using run_one_timeslice

2005-09-08 Thread David Davis
Whatever dude... If you wanted to know what Rocco would do, then just email 
him, don't ask the list.

David

On 9/6/05, Jay Strauss <[EMAIL PROTECTED]> wrote:
> 
> David Davis wrote:
> > If you call $poe_kernel->run(); without any sessions created yet, then 
> it
> > will return immediately.
> >
> > Call that, then use run_one_timeslice and no warning will be produced.
> >
> > David
> >
> 
> That works fine. But now I'm faced with a dilemma, Rocco said to do it
> a procedural way, and he's the author.
> 
> oh oh
> 
> Jay
>


Re: Getting "POE::Kernel's run() method was never called" when using run_one_timeslice

2005-09-05 Thread David Davis
If you call $poe_kernel->run(); without any sessions created yet, then it 
will return immediately.

Call that, then use run_one_timeslice and no warning will be produced.

David

On 9/5/05, Jay Strauss <[EMAIL PROTECTED]> wrote:
> 
> Rocco Caputo wrote:
> > On Sep 5, 2005, at 17:43, Jay Strauss wrote:
> >
> >> I'm getting "POE::Kernel's run() method was never called." error when
> >> my script that calls the code below ends.
> >>
> >> I could put a ->run and ->("shutdown") into a sub DESTROY. But is
> >> there a way I'm supposed to avoid this error.
> >
> >
> > POE::Kernel isn't designed to run without run() being called from the
> > top level. Your code avoids some initialization and cleanup that run ()
> > does.
> >
> 
> Rocco, I appreciate the code. I'm not familiar with socket programming
> enough to feel comfortable rolling my own.
> 
> Based on what you said, I don't understand then how you'd ever use the
> run_one_timeslice method then. If you need to call ->run, then your
> program is stuck running and doesn't drop down to further code, until
> "shutdown".
> 
> How would you ever get to the code to do the run_one_timeslice portion?
> 
> Thanks
> Jay
>


Re: How to disconnect the client or when to know that the conversation is complete

2005-08-01 Thread David Davis
You just delete your readwrite wheel after all the data is flushed.

David

On 8/1/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> 
> O.K.
> And how to disconnect the client if the connection is made through
> POE::Wheel::SocketFactory.I thik there is no shutdown method there.
> Pl. reply I shall be very grateful.
> --
> Regards
> Abhishek jain
> 
> Original Message:
> -
> From: Rocco Caputo [EMAIL PROTECTED]
> Date: Fri, 29 Jul 2005 22:19:35 -0400
> To: poe@perl.org
> Subject: Re: How to disconnect the client or when to know that the
> conversation is complete
> 
> 
> On Fri, Jul 29, 2005 at 09:56:06PM +0530, Abhishek Jain wrote:
> > The server on successful connection by a client sends a welcome
> > message . Client sends a request and server responds and immediately
> > after that the conversation must stop.
> 
> 1. Client connects.
> 2. Server says hello.
> 3. Client sends request.
> 4. Server sends response.
> 5. Server closes connection after response is flushed.
> 
> > I have tried writing $_[KERNEL]->yield("shutdown") code in the
> > ServerFlushed but the control perhaps do not passes to this function
> > .
> 
> The steps above show that the server must initiate the disconnection
> after the response is sent.  The server does not have a ServerFlushed
> callback.  Rather, it has a ClientFlushed, but you should not need to
> use it in most cases.
> 
> POE::Component::Server::TCP contains logic to automatically delay the
> shutdown until all buffered output is flushed.  Therefore you may call
> $_[KERNEL]->yield("shutdown") immediately after sending the response
> in #4.  The server component will ensure the response is sent.
> 
> > Also i would like  to see suggestions that whether this server can
> > handle multiple simultaneous connections from many different
> > clients.
> 
> POE::Component::Server::TCP handles multiple concurrent connections.
> 
> --
> Rocco Caputo - http://poe.perl.org/
> 
> 
> mail2web - Check your email from the web at
> http://mail2web.com/ .
> 
> 
>


Re: nobody knows how to do that?

2005-05-19 Thread David Davis
I'm unaware of a way to do that with LaDBI

Use EasyDBI instead. :P

I'm assuming you are using mysql here:

 $_[KERNEL]->post( 'EasyDBI',
insert => {
sql => "insert into tbl values(nextval('tbl_id'),?)",
placeholders => [ 'some_value' ],
event => sub {
  croak $_[0]->{error} if ($_[0]->{error});
  print "insert id: ".$_[0]->{insert_id}."\n";
 },
 last_insert_id => 'SELECT LAST_INSERT_ID()',
}
);

event can be a postback, coderef, or event name.
Easy enough?

David

On 5/18/05, Laura <[EMAIL PROTECTED]> wrote:
> I just need to insert the data and get back it`s id
> immediately...
> 
> $sql="insert into tbl
> values(nextval('tbl_id'),'some_value')";
>$k->post("ladbi" => "do",
> SuccessEvent => "insert",
> FailureEvent => "failed",
> HandleId => $dbh_id,
> Args => [ $sql],
> );
> 
> please help, thank you
> ---
> Professional hosting for everyone - http://www.host.ru
>


Re: Newbie to POE. Please help me

2005-04-27 Thread David Davis
http://wilmore.pm.org/meetings/apr2001/poe.pdf

:)

On 4/27/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> 
> 
> 
> There is an excellent tutorial-type presentation by Matt Sergeant that was
> online at one time and is referenced in the POE Tutorials section (
> http://poe.perl.org/?Tutorials). But I haven't been able to access it 
> there
> for over a year. Here is the url:
> http://axkit.org/docs/presentations/tpc2002/. I sent an email to Matt to
> see if he can get it back online. If that doesn't work maybe someone on
> this list can get a copy of it loaded on poe.perl.org<http://poe.perl.org>
> .
> -
> Lance Braswell - + 1 469 357 6112
> 
> 
> "Abhishek Jain"
> <[EMAIL PROTECTED]>
> To
> 04/27/2005 03:39 
> PM cc
> 
> Subject
> Newbie to POE. Please help me
> 
> Hi Friends,
> I am working with perl from the past 2 years and have in mine job been
> assigned a project to be made in POE. I have tried various tutorial at POE
> but wasn't able to figure out it. It's event driven concepts , Kernel,
> Wheel, when will an event be fired up etc. appear too difficult to me.
> I have even looked at the archieves of this mailig list but of no great
> help.
> I need your help.
> Can anyone here give me a link to a good tutorial on POE or if possible
> please give me some explanation to me.
> Since i have been given the project long time back any help and a quick
> help will be highly appreciated.
> Please do help me.
> I shall be very very grateful.
> Thanks in advance for your time and effort.
> --
> Regards
> Abhishek jain
> 
> 


-- 
David Davis
Perl Developer
http://teknikill.net/

$7.95 per month hosting
WITH ssh access
http://hosting.teknikill.net/


Re: HTTPD meta refresh

2005-04-22 Thread David Davis
sub handler {
my ($request, $response) = @_;
$response->code(302);
$response->header('Location' => 'http://somewhere/blah');
return RC_OK;
}


On 4/22/05, Mathieu Longtin <[EMAIL PROTECTED]> wrote:
> 
> If you're using POE::Component::Server::HTTP, you have to
> set the 302 code in the response object, and then return
> RC_OK from your handler. The component uses the return
> values RC_OK, RC_DENY (not handled), RC_CONTINUE (show this
> request to the next matching handler).
> 
> What the browser gets is the code you set in the $response
> object.
> 
> 
> --- Bob Faist <[EMAIL PROTECTED]> wrote:
> > Not really a question but just sharing some info
> >
> > I used the suggestion by David to set the "Location" in
> > the header and
> > the 302 status code. It turns out the problem was the
> > HTTP status code
> > I was returning from the content handler function was
> > hard coded to be
> > RC_OK. If I set the status code to be 302 in the
> > HTTP::Response object
> > and then also returned "302" in the content handler
> > function, the
> > redirect in IE6 works just fine.
> >
> > Thanks,
> > Bob
> >
> >
> > -Original Message-
> >
> >
> **
> > Confidentiality Notice
> > The information contained in this e-mail is confidential
> > and intended for
> > use only by the person(s) or organization listed in the
> > address. If you have
> > received this communication in error, please contact the
> > sender at O'Neil &
> > Associates, Inc., immediately. Any copying,
> > dissemination, or distribution
> > of this communication, other than by the intended
> > recipient, is strictly
> > prohibited.
> >
> **
> >
> > From: David Davis [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, April 14, 2005 1:26 PM
> > To: Bob Faist
> > Cc: poe@perl.org
> > Subject: Re: HTTPD meta refresh
> >
> > This isn't really a POE question, but I'll answer it.
> >
> >
> http://www.w3.org/TR/REC-html40/struct/global.html#edef-META
> > -
> > Some user agents support the use of meta to refresh the
> > current page
> > after a specified number of seconds, with the option of
> > replacing it by
> > a different URI.
> > Authors should not use this technique to forward users to
> > different
> > pages, as this makes the page inaccessible to some users.
> > Instead,
> > automatic page forwarding should be done using
> > server-side redirects.
> > -
> >
> > Use a Location: header and a 302 status to redirect the
> > browser.
> > --
> > David Davis
> > Perl Developer
> > http://teknikill.net/
> >
> > $7.95 per month hosting
> > WITH ssh access
> > http://hosting.teknikill.net/
> >
> >
> > On 4/14/05, Bob Faist <[EMAIL PROTECTED]> wrote:
> > > POE 0.3009 and POE::Component::Server::HTTP question
> > >
> > > Windows XP
> > > CGI::Application
> > >
> > > The content handler provides a login page URL which is
> > rendered
> > > correctly. Once the form is submitted, the user is
> > validated and the
> > > following HTML is returned to POE.
> > >
> > > 
> > > 
> > > Authorizing...
> > >  > >
> >
> content="0;URL=http://bfaist-ws:32080/cgi-bin/emsng_ietm_poe/IETM_Menu
> > > .p
> > > l">
> > > 
> > > 
> > >
> > > This meta refresh works OK in Firefox but does not work
> > OK in IE6.
> > > Any reasons why this would not work for IE? If I run
> > the CGI::App
> > > alone with Apache, it handles the meta refresh OK in
> > Firefox and IE6.
> > >
> > > There header attributes are being set in the response
> > object.
> > >
> > > [Thu Apr 14 12:30:53 2005] server.pl: Setting Date
> > equals Thu, 14 Apr
> > > 2005 16:30:53 GMT
> > > [Thu Apr 14 12:30:53 2005] server.pl: Setting
> > Set-Cookie equals
> > >
> >
> emsng_ietm_poe_session_key=acb3e60100360eb087b5f1219865c730;
> > path=/
> > > [Thu Apr 14 12:30:53 2005] server.pl: Setting
> > Content-Type equals
> > > text/html; charset=ISO-8859-1
> > >
> > >
> >
> **
> > > Confidentiality Notice
> > > The information contained in this e-mail is
> > confidential and intended
> > > for use only by the person(s) or organization listed in
> > the address.
> > > If you have received this communication in error,
> > please contact the
> > > sender at O'Neil & Associates, Inc., immediately. Any
> > copying,
> > > dissemination, or distribution of this communication,
> > other than by
> > > the intended recipient, is strictly prohibited.
> > >
> >
> **
> > >
> > >
> >
> 
> __
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> 



-- 
David Davis
Perl Developer
http://teknikill.net/

$7.95 per month hosting
WITH ssh access
http://hosting.teknikill.net/


Re: HTTPD meta refresh

2005-04-14 Thread David Davis
This isn't really a POE question, but I'll answer it.

http://www.w3.org/TR/REC-html40/struct/global.html#edef-META
-
Some user agents support the use of meta to refresh the current page after
a specified number of seconds, with the option of replacing it by a
different URI.
Authors should not use this technique to forward users to different
pages, as this
makes the page inaccessible to some users. Instead, automatic page
forwarding should
be done using server-side redirects.
- 

Use a Location: header and a 302 status to redirect the browser.
-- 
David Davis
Perl Developer
http://teknikill.net/

$7.95 per month hosting
WITH ssh access
http://hosting.teknikill.net/


On 4/14/05, Bob Faist <[EMAIL PROTECTED]> wrote:
> POE 0.3009 and POE::Component::Server::HTTP question
> 
> Windows XP
> CGI::Application
> 
> The content handler provides a login page URL which is rendered
> correctly.  Once the form is submitted, the user is validated and the
> following HTML is returned to POE.
> 
> 
>   
>Authorizing...
>content="0;URL=http://bfaist-ws:32080/cgi-bin/emsng_ietm_poe/IETM_Menu.p
> l">
>   
> 
> 
> This meta refresh works OK in Firefox but does not work OK in IE6.  Any
> reasons why this would not work for IE?  If I run the CGI::App alone
> with Apache, it handles the meta refresh OK in Firefox and IE6.
> 
> There header attributes are being set in the response object.
> 
> [Thu Apr 14 12:30:53 2005] server.pl: Setting Date equals Thu, 14 Apr
> 2005 16:30:53 GMT
> [Thu Apr 14 12:30:53 2005] server.pl: Setting Set-Cookie equals
> emsng_ietm_poe_session_key=acb3e60100360eb087b5f1219865c730; path=/
> [Thu Apr 14 12:30:53 2005] server.pl: Setting Content-Type equals
> text/html; charset=ISO-8859-1
> 
> **
> Confidentiality Notice
> The information contained in this e-mail is confidential and intended for
> use only by the person(s) or organization listed in the address. If you have
> received this communication in error, please contact the sender at O'Neil &
> Associates, Inc., immediately. Any copying, dissemination, or distribution
> of this communication, other than by the intended recipient, is strictly
> prohibited.
> **
> 
>


Re: Syslog child on Windows

2005-03-31 Thread David Davis
There are quite a few DBI components for POE.  You could use one of
those.  I'm partial to mine, but you should judge for yourself.

http://cpan.teknikill.net/?poe*dbi

-- 
David Davis
Perl Programmer
http://teknikill.net/

$7.95 per month hosting
WITH ssh access
http://hosting.teknikill.net/

On Thu, 31 Mar 2005 11:41:28 -0500, Jim <[EMAIL PROTECTED]> wrote:
> I have a perl Syslog server setup on a windows box because it's connected to
> a RAID Array.  I'm using POE as the Syslog server code and I'm storing the
> syslog data into a DB2 database.  Here is what I currently have:
> 
> use warnings;
> use strict;
> 
> use POE;
> use POE::Component::Server::Syslog;
> use DBI; # library for performing database functions
> use DBD::DB2;
> use DBD::DB2::Constants;
> # use Mail::SendMail;
> 
> POE::Component::Server::Syslog->spawn(
> BindAddress => '129.37.2.201',
> InputState => \&client_input,
> ErrorState => \&client_error,
> );
> 
> my $debug = 1;
> 
> $poe_kernel->run();
> 
> ##
> 
> sub client_input {
> 
>   # Get the syslog hash
>   my $msg = $_[ARG0];
>   my $databaseHandle;
>   my $connectFailureFlag = 0;
>   my $search;
>   my $sth;
>   my $dbName = "vpn";
>   # Parse the data for DB entry
>   $msg->{'msg'} =~ /^(.*?) (\d+)\/(\d+)\/(\d+) (\d+):(\d+):(\d+)\.(\d+)
> SEV=. (.*?)$/;
> 
>   if ($debug) {
>print "Host: ".$msg->{'host'}."\n";
>print "Severity: ".$msg->{'severity'}."\n";
>print " Msg: ".$msg->{'msg'}."\n";
>my $databaseHandle = DBI->connect("DBI:DB2:$dbName","x","xx") or
> $connectFailureFlag = 1;
> if ($connectFailureFlag == 1){ warn "Unable to establish with
> DB2:$dbName due to $DBI::errstr\n"; }
> elsif ($connectFailureFlag == 0){ # connected to DB
>  $search = "INSERT INTO VPN.SYSLOG_C3K (DATE_TIME, DEVICE, SEV, MSG)
> values('$4-$2-$3-$5.$6.$7.$8', '".$msg->{'host'}."', ".$msg->{'severity'}.",
> '$9')";
>   $sth = $databaseHandle->prepare("$search"); # prepare the statement to
> read from the DB
>   $sth->execute(); # execute the query
> $sth->finish;
>  $databaseHandle->disconnect or warn "Disconnection failed:
> $DBI::errstr\n";
>}
>print "$2.$3.$4.$5.$6.$7.$8 $1 $9\n\n";
>   } # if ($debug)
> }
> 
> sub client_error {
>   # Something went wrong with the syslog message
>   # Figure out what to do, if anything, in this case later
> warn "BAD MESSAGE: $_[ARG0]";
> }
> 
> What I'd like to do is collect the syslog data into an array while having
> another process pull the data out of that array and put into the database.
> That way, I'm not creating database connections everytime I get a syslog
> message.  Hopefully I'm clear in what I'm asking for. :-)
> 
>


Re: Apache::Backend::POE (Was: Apache::Benchmark::POE)

2005-03-26 Thread David Davis
Oops, sorry for the confusion in the title.
At least I got the module name right :)

David


On Fri, 25 Mar 2005 16:25:36 -0800, David Davis <[EMAIL PROTECTED]> wrote:
> Here it is...
> 
> http://teknikill.net/files/Apache-Backend-POE-0.01.tar.gz
> 
> --
> David Davis
> Perl Programmer
> http://teknikill.net/
> 
> Try CPAN Suggest!
> http://cpan.teknikill.net/
>


Apache::Benchmark::POE

2005-03-25 Thread David Davis
Here it is...

http://teknikill.net/files/Apache-Backend-POE-0.01.tar.gz

-- 
David Davis
Perl Programmer
http://teknikill.net/

Try CPAN Suggest!
http://cpan.teknikill.net/


Re: KILL-ing my POE app

2005-03-25 Thread David Davis
You can't trap SIGKILL, but you can trap SIGTERM.  Change it to TERM
and try kill -TERM 

On Fri, 25 Mar 2005 23:00:46 +0100, Bas Schulte <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> my POE app install a handler for sigint ans sigkill
> ($poe_kernel->sig(INT  => 'sigint');, $poe_kernel->sig(KILL  =>
> 'sigint');)), this works fine when I start the app and hit ctrl-c.
> However, when I kill it using kill on the commandline with the pid of
> the POE app, it just prints "Terminated" and abruptly stops, without
> calling my installed handler.
> 
> BTW, I'm not using "kill -KILL pid", just 'kill pid".
> 
> This on mac os 10.2, gonna try it on a linux, see if there's a subtle
> difference there ;)
> 
> Regards,
> 
> Bas.
> 
> 


-- 
David Davis
Perl Programmer
http://teknikill.net/

Try CPAN Suggest!
http://cpan.teknikill.net/


Re: anyone using any of the HTTP server components in a heavy use environment?

2005-03-25 Thread David Davis
I'm releasing Apache::Backend::POE today, look for it on CPAN soon.
I'll also post the url on the list for those that want it sooner.

David

On Fri, 25 Mar 2005 19:20:40 +, Matt S Trout
<[EMAIL PROTECTED]> wrote:
> On Thu, Mar 24, 2005 at 04:30:54PM -0800, David Davis wrote:
> > I can give you what I have written... Apache::Backend::POE
> >
> > It hasn't been heavily tested or given a proper build and docs..but I
> > can help you get started using it.
> >
> > It caches connections ala Apache::DBI too.
> >
> > Interested?
> 
> I'd be fascinated to see this; I've been pondering something along the
> same lines, although I was looking at welding it into Maypole or similar.
> 
> Any chance you could either stick a copy to play with up to download
> somewhere? (or mail it off-list if necessary, but I think there're a few
> people wanting copies now :)
> 
> --
> Matt S TroutBrag sheet:http://trout.me.uk/services.html
> LAMP, InfrastructureContact:   [EMAIL PROTECTED]
>and Automation
>  specialist   Do it once. Do it right.
> 


-- 
David Davis
Perl Programmer
http://teknikill.net/

Try CPAN Suggest!
http://cpan.teknikill.net/


Re: anyone using any of the HTTP server components in a heavy use environment?

2005-03-24 Thread David Davis
I can give you what I have written... Apache::Backend::POE

It hasn't been heavily tested or given a proper build and docs..but I
can help you get started using it.

It caches connections ala Apache::DBI too.

Interested?

David

On Thu, 24 Mar 2005 23:39:01 +0100, Bas Schulte <[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> On donderdag, maa 24, 2005, at 22:04 Europe/Amsterdam, John
> Napiorkowski wrote:
> 
> > I'm wondering if anyone has used any of the HTTP
> > servers that come with POE in a semiproduction/medium
> > to heavy use environment?  What I mean by this is
> > something that might server 40-60 connections per
> > minute, including some database driven pages, etc.
> 
> Ok, I have a similar question, yet my definition of medium to heavy is
> different ;)
> 
> How do POE::Component::Server::HTTP and/or POE::Component::Server::TCP
>   handle loads of 40-60 connections/requests *per second* on a
> reasonably (r)(d)ecent intel box with linux on it?
> 
> I'm using apache 1.x/mod_perl as an application server for this now
> (doesn't serve html and stuff), with POE on the backend for different
> stuff. Might be nice to use POE to build a lean and mean app server...
> 
> Anyone care to comment on this? I'd love to try it out but as always:
> short on time to actually do it and load-test it.
> 
> Thanks,
> 
> Bas.
> 
> 


-- 
David Davis
Perl Programmer
http://teknikill.net/

Try CPAN Suggest!
http://cpan.teknikill.net/


Re: FollowTail

2005-03-01 Thread David Davis
Replace your wheel  (probably in $heap->{wheel} or something) with a
new wheel with the new filename.

David

On Tue, 1 Mar 2005 15:09:09 -0800 (PST), Lamb Joseph
<[EMAIL PROTECTED]> wrote:
> I have a log file that ends when it grows to 52MB. The
> last line of the log file displays the next log's path
> and name.
> 
> How do I restart the wheel with a new file name?
> 
> =
> Joseph Lamb
> 
> 
> __
> Do you Yahoo!?
> Yahoo! Mail - Easier than ever with enhanced search. Learn more.
> http://info.mail.yahoo.com/mail_250
> 


-- 
David Davis
Perl Programmer
http://teknikill.net/

Try CPAN Suggest!
http://cpan.teknikill.net/


Re: catching exceptions in sessions

2005-02-01 Thread David Davis
Yes there is.

POE::Exceptions

http://search.cpan.org/dist/POE-Exceptions/lib/POE/Exceptions.pm

-- 
David Davis
Perl Programmer
http://teknikill.net/

Try CPAN Suggest!
http://cpan.teknikill.net/

On Tue, 1 Feb 2005 08:07:35 -0800 (PST), Mathieu Longtin
<[EMAIL PROTECTED]> wrote:
> Hi,
> 
> is there a way in a POE::Session to put an eval { } around
> all the states, and if an exception occurs, forward it to
> another state?
> 
> Thanks
> 
> -Mathieu
> 
> 
> __
> Do you Yahoo!?
> Yahoo! Mail - Find what you need with new enhanced search.
> http://info.mail.yahoo.com/mail_250
>


Re: POE sessions, clients, confused

2005-01-27 Thread David Davis
Response below.

On Thu, 27 Jan 2005 20:15:22 +0100, Bas Schulte <[EMAIL PROTECTED]> wrote:
> Hi David,
> 
> On donderdag, jan 27, 2005, at 00:45 Europe/Amsterdam, David Davis
> wrote:
> 
> >> Can I start a new session in client_input, start a new POE::Wheel::Run
> >> from there *in* the ClientInput state? Or does that create a
> >> (parent-child?) dependency with the POE::Component::Server::TCP
> >> session? That runs sour when the client disconnects?
> >
> > Yes it does create a wheel in that session handling the input for that
> > client.
> > Your session_stdout even is getting sent to that session, and you
> > don't have an event by that name in that session created by
> > Server::TCP.
> 
> Yes, this part I understand now :)
> 
> 
> >> sub client_input
> >> {
> >> my ($session, $heap, $kernel, $input, $wheel) = @_[ SESSION, HEAP,
> >> KERNEL, ARG0, ARG1 ];
> >>
> >> ## pass client's input and reference to our wheel
> >>
> >> $kernel->post($heap->{controllingSession}, 'do_the_start', $input,
> >> $heap->{client});
> >
> > Don't pass the client wheel, that's bad when using post.
> 
> Argh. I don't understand why I can't pass the reference to the wheel
> though. Why is it bad?

It has to do with garbage collection.  Wheels are linked to the
session, and if you want to have it properly clean up and disconnect,
don't pass it around.

Rocco, please chime in if I'm wrong.

> 
> >  It would be
> > better if you used $kernel->post($_[SENDER] => send => 'OK');  and
> > setup an inline_state called send that did a if ($heap->{client}) {
> > $heap->{client}->put($_[ARG0]); }
> 
> I tried it, seems to work fine.

It seems to...

> 
> 
> > You could also change this to a call() and be ok with using it as a
> > hack.  Just don't pass wheel handles around freely.
> 
> I don't want a hack :)

Nor do I want to suggest one.

> I still don't understand what the "right" solution is though. I saw
> something about detaching a session from it's parent as well. Maybe I
> can create a session in the tcp server session, start the wheel in that
> child session and then detach that session from the tcp server's
> session. Sounds ok to me but I'm still not sure what the "right" way is.
> 

You could do that.  I have never tried it though.  Something like this
might work:

POE::Session->create(
  inline_states => {
_start => {
$_[HEAP]->{wheel} = POE::Wheel::Run->...
$_[KERNEL]->detach_myself();
},
 [ other events ]
  },
);

> 
> > Just don't pass wheel handles around freely.
> 
> Does that mean I can't pass the result of "POE::Wheel::Run->new(...)"
> around as well? I have this:
> 
> my $child = new POE::Wheel::Run();
> 
> Then I keep the $child around so I can kill it later on. Is that bad?

No, keeping it in the heap is fine. When the wheel dies off (program
finishes) the session will clean itself up and go away.

> 
> Thanks,
> 
> Bas.
> 
> 

-- 
David Davis
Perl Programmer
http://teknikill.net/

Try CPAN Suggest!
http://cpan.teknikill.net/


Re: PoCoCl::UA related crash

2005-01-27 Thread David Davis
I suggest reporting this bug:

http://rt.cpan.org/NoAuth/ReportBug.html?Queue=POE%3A%3AComponent%3A%3AClient%3A%3AUseragent'

-- 
David Davis
Perl Programmer
http://teknikill.net/

Try CPAN Suggest!
http://cpan.teknikill.net/

On Thu, 27 Jan 2005 13:01:47 -0500, Ed Heil <[EMAIL PROTECTED]> wrote:
> Hi -- I'm pretty new to POE, and still getting my bearings, so I
> apologize in advance for any vagueness and imprecision in this
> question.
> 
> I'm working with a colleague on a client-server application which
> previously used plain vanilla LWP to query the server, and recently
> we've overhauled and POE-ified it and replaced the ordinary LWP with
> PoCoCl::UA.  (Version 0.06)
> 
> It works great most of the time, but every so often, the app will die
> with a message that looks like this:
> 
> Can't use string ("") as a subroutine ref while "strict refs" in use at
> /Library/Perl/5.8.1/POE/Component/Client/UserAgent.pm line 325.
> 
> (note that the line number is a bit off from the standard distribution
> because I've been hacking up my copy of UserAgent.pm with debug output
> around this point.)
> 
> I have not managed to duplicate this in any kind of a demo, but by
> putting in debug messages I've got a clearer picture of the
> circumstances which obtain when this happens.
> 
> It happens within POE/Component/Client/UserAgent.pm, of course, within
> the subroutine "_pococ_ua_postback",  on this line:
> 
> $entry -> postback -> ($request, $response, $entry);
> 
> It happens because $entry->postback is at this point "undef."
> 
> using the caller() function, I've found out $entry->postback becomes
> "undef" under the following conditions:
> 
> LWP::Parallel::UserAgent::_perform_read(), line 1153, calls
> $self->on_failure
> Po::Co::Cl::UserAgent::on_failure calls $object -> _pococ_ua_postback
> At this point, _pococ_ua_postback calls $entry->postback, which is
> defined and does NOT crash.
> at this point, $entry->postback is, according to Data::Dumper:
>   $VAR1 = bless( sub { "DUMMY" }, 'POE::Session::Postback' );
> 
> Very soon thereafter, though:
> LWP::Parallel::UserAgent::_perform_read(), line 1171, calls
> $self->on_return
> Po::Co::Cl::UserAgent::on_return calls $object -> _pococ_ua_postback
> At this point, _pococ_ua_postback calls $entry->postback, which is
> undefined, and the app crashes.
> 
> at this point, $entry->postback is: $VAR1 = undef;
> 
> The problem does not occur except under these conditions --
> _perform_read first fails, then calls the postback, and then succeeds,
> and tries to call it again, and can't, because it's undef.
> 
> I definitely am not well enough versed in POE's guts to say whether
> this is a problem with PoCoCl::UA or something about the postbacks
> we're sending it or what.
> 
> If anyone could suggest some useful further steps to take to try to
> figure out what is going on, I'd be very grateful.
> 
> This happens only sporadically, and it is less common when I'm on a
> particularly fast, low-latency network connection and more common when
> I'm on a slower one.  So it may have something to do with the length of
> time it takes for a request to return.
> 
> Thanks very much!
> 
> Ed Heil
> 
>


Re: POE sessions, clients, confused

2005-01-26 Thread David Davis
Response within,

On Wed, 26 Jan 2005 22:36:25 +0100, Bas Schulte <[EMAIL PROTECTED]> wrote:
> Hi David,
> 
> On woensdag, jan 26, 2005, at 20:01 Europe/Amsterdam, David Davis wrote:
> 
> > Setup another session to handle wheel run, and use $_[SENDER] to reply
> > back if the client is still connected.
> 
> That's a bit too compact for me :)
> 
> Where do I do what, that's basically my problem:
> 
> Can I start a new session in client_input, start a new POE::Wheel::Run
> from there *in* the ClientInput state? Or does that create a
> (parent-child?) dependency with the POE::Component::Server::TCP
> session? That runs sour when the client disconnects?

Yes it does create a wheel in that session handling the input for that client.
Your session_stdout even is getting sent to that session, and you
don't have an event by that name in that session created by
Server::TCP.

> 
> I'm confused as to what session should manage the events fired by the
> POE::Wheel that manages my child. I think I need to "detach" the
> started wheel from the tcp session but don't know how.
> 
> I now do this:
> 
> POE::Session->create(
> inline_states =>
> {
>_start=> \&controller_start,
> 
>do_the_start => \&do_the_start,
> 
>...
> },
> );
> 
> sub controller_start
> {
> my ($kernel, $heap, $session) = @_[KERNEL, HEAP, SESSION ];
> 
> $heap->{server} = new POE::Component::Server::TCP(
>   Alias   => "controld",
>   Port=> ,
>   ClientInput => \&client_input,
>   ClientConnected => \&client_connected,
>   Args=> [ $session ],
> );
> }
> 
> sub do_the_start
> {
> my ($kernel, $heap, $session, $input, $client) = @_[KERNEL, HEAP,
> SESSION, ARG0, ARG1];
> 
> my $child = new POE::Wheel::Run(
> 
>Program=> $input,  ## Not recommended :)
> 
>...
> 
>StdoutEvent=> 'session_stdout',
> 
>...
> );
> 
> ## If this went well, send response back to client:
> 
> client->put("OK");

Missing a $ here

> }
> 
> ...
> 
> $poe_kernel->run();
> 
> sub client_connected
> {
> my ($session, $heap, $kernel, $controllingSession) = @_[ SESSION,
> HEAP, KERNEL, ARG0];
> 
> $heap->{controllingSession} = $controllingSession;
> }
> 
> sub client_input
> {
> my ($session, $heap, $kernel, $input, $wheel) = @_[ SESSION, HEAP,
> KERNEL, ARG0, ARG1 ];
> 
> ## pass client's input and reference to our wheel
> 
> $kernel->post($heap->{controllingSession}, 'do_the_start', $input,
> $heap->{client});

Don't pass the client wheel, that's bad when using post.  It would be
better if you used $kernel->post($_[SENDER] => send => 'OK');  and
setup an inline_state called send that did a if ($heap->{client}) {
$heap->{client}->put($_[ARG0]); }

You could also change this to a call() and be ok with using it as a
hack.  Just don't pass wheel handles around freely.

> }
> 
> I basically do not respond from within the ClientInput state, but do a
> post to another session, with both the client's input and a reference
> to the tcp wheel.
> 
> This works but I'm somewhat confused as to why I can't just fork a
> child from within the ClientInput state using POE::Wheel::Run,
> conceptually that is. So I'd love someone explain me the concept ;)

See above. The wheel becomes a child of the client control session.

> 
> Regards,
> 
> Bas.
> 
> 

I hope this helps.

-- 
David Davis
Perl Programmer
http://teknikill.net/

Try CPAN Suggest!
http://cpan.teknikill.net/


Re: POE sessions, clients, confused

2005-01-26 Thread David Davis
Setup another session to handle wheel run, and use $_[SENDER] to reply
back if the client is still connected.

-- 
David Davis
Perl Programmer
http://teknikill.net/

Try CPAN Suggest!
http://cpan.teknikill.net/

On Wed, 26 Jan 2005 19:43:15 +0100, Bas A. Schulte
<[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> I have a conceptual question about POE and it's sessions that I have
> some trouble with.
> 
> I'm trying to write a POE::Component::Server::TCP server that reads
> command lines from the client (well, not really, in reality it's some
> sort of reference that gets fed to another application on it's command
> line), then needs to execute that command, and respond with feedback
> that the process was started. The new process will run for quite some
> time, whilst the client will disconnect before that.
> 
> In short: clients logs in on some port, says "launch b", then a process
> "launch" is exec-ed using POE::Wheel::RUN, and that child is monitored
> by the main session.
> 
> My simple initial approach was this:
> 
> my $server = new POE::Component::Server::TCP(
>Alias   => "lala",
>Port=> ,
>ClientInput => \&client_input,
> );
> 
> $poe_kernel->run();
> 
> sub client_input
> {
>my ($input) = @_[ ARG0 ];
> 
>...
> 
>my $child = new POE::Wheel::Run(
> 
>   Program=> $input,  ## Not recommended :)
> 
>   ...
> 
>   StdoutEvent=> 'session_stdout',
> 
>   ...
>);
> 
>$heap->{client}->put("Ok, I started $input for you successfully");
> }
> 
> This doesn't work: the 'StdoutEvent' event is posted to the session
> that's running client_input (session created by
> POE::Component::Server::TCP for this connection).
> 
> How am I supposed to handle this?
> 
> Right now, I validate the client input, then put the request to start on
> a queue that I check in another session. This works but it won't report
> back a failure to launch the process to the client. For example, when
> the process to launch is a perl script that fails to compile or
> something.
> 
> Maybe I need to put the request to start on the queue, AND somehow add
> the client session reference to it as well, and respond back from my
> main session instead of directly in client_input?
> 
> I'm somewhat confused right now, hope someone can clear this one up :)
> 
> Thanks in advance,
> 
> Bas.
>


Re: New user; some input

2004-12-19 Thread David Davis
Hi Nadim, 

Welcome to POE :)

On Mon, 20 Dec 2004 01:49:25 +0100, nadim khemir <[EMAIL PROTECTED]> wrote:
> Hi, as the subject says it, "new user" so expect the unexpected.
> 
> I've been lurking for some times and I will try to use POE during the
> holidays (I always have a Xmas project). The learning curve is steep. Not
> because it's complex but more because the doc is a bit difficult to follow
> (or find).
> 
> Some input:
> 
> 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)

> The MP3 player example (which would have been cool to see working as I want
> to try a curses based interface to start with) doesn't work. The PoCo::MP3
> doesn't exist anymore on CPAN and installing it manually doesn't help as
> POE complains about the usage of a deprecated function.

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?)

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 may not be what you want if you are strickly wanting a curses based program.

> 
> This is a start with three step back and none forward. I hope my luck gets
> better.
> 
> Cheers, Nadim.
> 
> 

-- 
David Davis
Perl Programmer
http://teknikill.net/


Re: How to print each event before it's dispatched?

2004-12-08 Thread David Davis
Hi Tim, 

Here's something better:

http://search.cpan.org/~rcaputo/POE-0.3003/lib/POE/Kernel.pm#Kernel's_Debugging_Features

You can turn on the TRACE debug flags and it will spit out everything
the kernel is doing.

On Wed, 8 Dec 2004 16:11:44 -0600, Tim Klein
<[EMAIL PROTECTED]> wrote:
> POE folks:
> 
> What's the best way to get a log of every event that gets dispatched?
> 
> I was hoping to use POE::API::Hooks to help me with that, but I'm
> having trouble figuring out what code to put inside the
> before_event_dispatch handler.  I've tried printing the result of
> POE::Kernel->get_active_event(), but it just prints as an empty
> string.
> 
> Surely I'm not the first person ever to want to watch events as they
> fly by, for debugging purposes.  Could someone point me toward some
> example code?
> 
> Thanks much for any help!
> 
> Tim Klein
> Dallas, Texas
> 
> 


-- 
David Davis
Perl Programmer
http://teknikill.net/


Re: datetime, inter-session alarms

2004-12-03 Thread David Davis
Theres a cool thing about wikis, anyone can add to it.

David

On Fri, 03 Dec 2004 15:55:09 -0500 (EST), [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> 
> 
> 
> On 03-Dec-2004 Rocco Caputo wrote:
> > On Thu, Dec 02, 2004 at 05:35:40PM -0800, Ofer Nave wrote:
> >>
> >> 2) Reading over the POE::Kernel docs, I noticed all the alarm and delay
> >> functions take an event name, but not a session id.  Is there never a
> >> situation where you'd want to set an alarm that would send an event to
> >> a session other than yours?
> > Making the task easier should be done as an abstraction outside
> > POE::Kernel rather than by wedging another timer method into it.
> 
> This could go in the cookbook :
> 
> my $o_session='alias';
> my $o_event='event';
> my @payload=(1..10);
> 
> my $t_event_name="deplayed-postback-".$n++;
> $poe_kernel->state($t_event_name=>sub {
> $poe_kernel->post($o_session, $o_event, @payload);
> $poe_kernel->state($t_event_name);
> });
> 
> $poe_kernel->delay_set($t_event, 10);
> 
> -Philip
> 
>


Re: FollowTail and seeking around

2004-10-18 Thread David Davis
You could do a tell() on the wheels' file handle which is located at
$wheel->[POE::Wheel::FollowTail::SELF_HANDLE]
or $wheel->[0] for short.

David

On Mon, 18 Oct 2004 13:48:44 +0200, Thomas Nagel <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> after playing around with POE::Wheel::FollowTail I wonder how to get the
> current position inside the read logfile, something like IO::File->getpos().
> 
> I noticed Seek and Seek back but nothing to find the current position
> inside the logfile let's say for saving its state for a _stop event.
> 
> Am I missing something? Or is there a way to figure that out?
> 
> Bye
> 
> Thomas
>


Re: poe Digest 17 Oct 2004 11:19:51 -0000 Issue 460

2004-10-18 Thread David Davis
use POE::API::Peek;

my $api = POE::API::Peek->new();
my @sessions = $api->session_list();

I recall there being a session module that you could assign sessions
to groups and  post to those groups, but can't remember the module
name.  I'll repost when I find it.

David

On Mon, 18 Oct 2004 15:44:03 +0100, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> Is there a kernel method to give me a list of all my sessions?
> I want to send an event to them all
> --
> David Ferrington, Database Services,
> perotsystems (tm)
> @ UBS, London.
> +44 20 756 81215
> 
> Visit our website at http://www.ubs.com
> 
> This message contains confidential information and is intended only
> for the individual named.  If you are not the named addressee you
> should not disseminate, distribute or copy this e-mail.  Please
> notify the sender immediately by e-mail if you have received this
> e-mail by mistake and delete this e-mail from your system.
> 
> E-mail transmission cannot be guaranteed to be secure or error-free
> as information could be intercepted, corrupted, lost, destroyed,
> arrive late or incomplete, or contain viruses.  The sender therefore
> does not accept liability for any errors or omissions in the contents
> of this message which arise as a result of e-mail transmission.  If
> verification is required please request a hard-copy version.  This
> message is provided for informational purposes and should not be
> construed as a solicitation or offer to buy or sell any securities or
> related financial instruments.
> 
> 


-- 
David Davis
Perl Programmer
http://teknikill.net/


Re: POE::Component::Client::HTTP streaming

2004-10-03 Thread David Davis
You should make sure you switch the filter AFTER the flush of all the
html data.  You can do this by adding a switch_filter inline state
that looks like this and yield to it with the request obj where you
now just switch the filter:

(I assume some things here...like the shutdown event as an example.)

$kernel->yield('switch_filter' => $request);

switch_filter => sub {
my ($kernel, $heap,$request) = @_[KERNEL, HEAP,ARG0];

unless ($heap->{client}) {
# client went away
return $kernel->yield('shutdown');
}

# check if ALL has been flushed
my $pending_bytes = $heap->{client}->get_driver_out_octets();
return $kernel->yield('switch_filter' => $request) if ($pending_bytes > 0);

$heap->{client}->set_output_filter(POE::Filter::Stream->new());
$kernel->post( "ua" => "request", "got_response", $request );
}

I do this with my upgrade of trickster, an mp3 streamer.  I was
actually thinking about writing a poe http proxy component yesterday. 
I ended up just using HTTP::Proxy for a windows pc on my lan.  I
didn't want to give it full internet access, just a few domains of my
choosing.  I may end up writing one, but I've got my hands in too many
other projects.

I'm xantus on irc.perl.org in #poe.

-- 
David Davis
Perl Programmer
http://teknikill.net/

On 3 Oct 2004 18:55:58 -, PerlDiscuss - Perl Newsgroups and
mailing lists <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> I am working on creating a proxy server based off the example given on the
> poe.perl.org website for a HTTP Proxy.
> 
> I have tried to change it to use streaming, however, I am finding that
> often the responses are incomplete and the wheels in
> POE::Component::Client::HTTP report read errors. This problem seems to be
> particularily bad when multiple requests are being made at the same time.
> However, when I do not use streaming, everything works fine.
> Interestingly, even without streaming there are still some read errors,
> but they do not seem to affect the content returned in the response
> object. I am making this proxy for a Windows system.
> 
> I would be very happy if you could quickly take a look at the code to try
> and see why this is not working. The problem may be in the way
> POE::Component::Client::HTTP handles streaming (I am using v 1.56
> 2004/07/13 18:02:37 rcaputo), but more likely its the way I am interfacing
> with-it.
> 
> The only routine changed heavily is handle_http_response from the example
> off the POE website.
> 
> Thanks in advance,
> George Pabst
> [EMAIL PROTECTED]
> 
> #!/usr/bin/perl
> 
> use warnings;
> use strict;
> 
> use POE;
> use POE::Component::Server::TCP;
> use POE::Component::Client::HTTP;
> use POE::Filter::HTTPD;
> 
> use HTTP::Response;
> use Compress::Zlib;
> 
> sub DUMP_REQUESTS ()  { 0 }
> sub DUMP_RESPONSES () { 0 }
> sub LISTEN_PORT (){ 8088 }
> 
> ### Spawn a web client to fetch requests through.
> 
> our $HTTP_VER = '1.0'; # Version of HTTP to report to servers and clients
> our $COMPRESS_TEXT = 1; # GZIP compress HTML and text
> our $CRLF = "\015\012";
> our $COMPRESS_TEXT = 0;
> 
> POE::Component::Client::HTTP->spawn(Protocol => "HTTP/$HTTP_VER", Alias =>
> 'ua', Agent => 'Mozilla/4.0 (compatible;)', Streaming => 4096, FollowRedirects
> => 0);
> 
> ### Spawn a web server.
> 
> # The ClientInput function is called to deal with client input.
> # ClientInput's callback function will receive entire HTTP requests
> # because this server uses POE::Filter::HTTPD to parse its input.
> #
> # InlineStates let us attach our own events and handlers to a TCP
> # server.  Here we attach a handler for the got_response event, which
> # will be sent to us by Client::HTTP when it has fetched something.
> 
> POE::Component::Server::TCP->new
>   ( Alias => "web_server",
> Port => LISTEN_PORT,
> ClientFilter => 'POE::Filter::HTTPD',
> 
> ClientInput => \&handle_http_request,
> InlineStates => { got_response => \&handle_http_response, },
>   );
> 
> ### Run the proxy until it is done, then exit.
> 
> POE::Kernel->run();
> exit 0;
> 
> ### Handle HTTP requests from the client.  Pass them to the HTTP
> ### client component for further processing.  Optionally dump the
> ### request as text to STDOUT.
> 
> sub handle_http_request {
> my ( $kernel, $heap, $request ) = @_[ KERNEL, HEAP, ARG0 ];
> 
> # If the request is really a HTTP::Response, then it indicates a
> # problem parsing the client's request. 

Re: Question about Kqueue support in POE

2004-10-01 Thread David Davis
Well, get started! :)

:pserver:[EMAIL PROTECTED]:/cvsroot/poe

David

On Fri, 1 Oct 2004 07:57:25 -0700 (PDT), Milscvaer
<[EMAIL PROTECTED]> wrote:
> Does POE support the Kqueue and Epoll event
> notification systems which are used on *BSD and Linux
> respectively?
> 
> The ability to have POE use these facilities would
> significantly improve the performance and scalability
> of POE in many cases and for many solutions these
> facilities will yield the best performance. Select()
> while it works well with small loads and is avialable
> on a wide range of platforms, and it is good to have
> select() support, it does have scalability issues in
> processing large loads, these issues are corrected by
> Kqueue and Epoll. Kqueue and Epoll are similar in
> their feature set, but Kqueue is perhaps more
> versatile than Epoll in that it seems to support event
> notification for a larger number of sources.
> 
> Adding support for both of these facilities to POE
> will have many benefits and I am surprised if it hasnt
> been done.
> 
> 
> __
> Do you Yahoo!?
> Yahoo! Mail is new and improved - Check it out!
> http://promotions.yahoo.com/new_mail
> 



-- 
David Davis
Perl Programmer
http://teknikill.net/


Re: [Fwd: Re: [PATCH] sslpoe-sanity-patch]

2004-08-23 Thread David Davis
I also use an adapted sslpoe in PoCo::Server::FTP, but its not stable.
 I guess I'm missing something.  I get alot of broken pipes and
handshake failures (I've also replaced the die's), hence I haven't
released the ssl version of PoCo::Server::FTP.  Maybe everyone can
post thier version somewhere, and we can compare notes
I'll be in #poe as xantus.

-- 
David Davis
Perl Programmer
http://teknikill.net/

On Sat, 21 Aug 2004 23:03:52 -0500, Nick Perez <[EMAIL PROTECTED]> wrote:
> Oops. Reply went to Rocco but not the list: here it is.
> 
> -- Nick
> 
> 
> -- Forwarded message --
> From: Nick Perez 
> To: Rocco Caputo 
> Date: Sat, 21 Aug 2004 23:01:32 -0500
> Subject: Re: [PATCH] sslpoe-sanity-patch
> 
> I guess I should have sent my changes upstream which are in fact the
> very same changes here. I use this in PoCo::Jabber::Client::XMPP and
> also in Server::XMPP but adapted it for my own uses. I am not offering
> to maintain it, but I will test it against my code and perhaps share
> notes on these changes and others with whomever does take up maintainership.
> 
> -- Nick
> 
> Rocco Caputo wrote:
> > On Sat, Aug 21, 2004 at 07:07:51PM -0400, Dylan William Hardison wrote:
> >
> >>Some changes to SslClient.pm in sslpoe:
> >>
> >>Remove reference to $socket from %Filenum_Object.
> >>Reason: It was keeping the tied filehandle from being DESTROYed.
> >>
> >>In the READ method: Change "die ("handshake failed");"
> >>to $! = 104; return undef.
> >>Reason: This makes POE handle it like a normal
> >>error. Dying allowed someone to send garbage via netcat
> >>and crash the program, thus adding a DoS to any server that
> >>uses SSL. That's not good.
> >>
> >>However, errno 104 is "Connection reset by peer", and this is a lie.
> >>Really the handshake failed... Perhaps some other value should be used
> >>for $!.
> >>
> >>Added a DESTROY method that calls CLOSE,
> >>as CLOSE is not called otherwise.
> >>
> >>The patch is attached.
> >
> >
> > KTHXAPPLIED!
> >
> >
> >>These changes are pretty trivial, and further
> >>work needs to be done on SslClient.pm to make it more robust. Also
> >>perhaps it should properly be named "SSLSocketWraper" or somesuch?
> >>The name is most confusing.
> >
> >
> > I wouldn't mind that, but I don't do enough SSL work (as in ANY) to
> > have a good idea what to do here.  If you'd like, I'm ok with someone
> > adopting and developing the project a bit.  Preferably someone who
> > uses it.
> >
> 
> 
>


Re: New PoCo Guidelines

2004-08-12 Thread David Davis
I like POEx also.

Philip:
If you wanted to get a postback for a certain session/event you could do:
ZipEvent => $kernel->ID_id_to_session($session_id)->postback('zip_event',@event_args),

pretty ugly and would cause an error for a session that didn't exist

I would like to suggest we use
poe://session/event
with an optional kernel param:
poe://[EMAIL PROTECTED]/event

David

On Tue, 10 Aug 2004 07:59:03 -0600, Wiggins d Anconia
<[EMAIL PROTECTED]> wrote:
> 
> 
> >
> > On 06-Aug-2004 Rocco Caputo wrote:
> > > The reasons for or against a loader class are fuzzy judgment calls,
> > > not good vs. evil issues.  One negative aspect I can think of offhand
> > > is that it makes class loading more complex.  You should decide
> > > whether the convenience outweighs the complexity.  Consider that the
> > > margin is ten characters narrower using "PoCo" (or even POEx, to
> > > follow in DBIx's footsteps).
> >
> > Let me through my vote in for POEx.
> >
> > -Philip
> >
> >
> 
> I'll add another. I think at the very least POE (with the 'E') needs to
> stay intact. I know the "chatting" convention has been to use 'PoCo',
> but to keep the two related I think the full 'POE' spelling needs to be
> included. The 'x' form definitely aligns well with the DBI -> DBIx
> pre-existing example.
> 
> http://danconia.org
>


New PoCo Guidelines

2004-07-26 Thread David Davis
After a talk in #poe, I was assigned with the task of coming up with
some guidelines for POE components.

I'd like as much feedback as I can get.  Then I'll setup a page on
poe.perl.org with what everyone has came up with, and hopefully some
guidelines will come of this.

Here's what we have so far:

-instatiation method
what should be used, new / spawn / create?

-interchangeable events & coderefs
event => 'event',
event => \&event,

-name space (kernel aliases other?)

-a standard way of describing a sess/event (for doco, and for debug messages)

-documentation standards (ie, how do we document the events received/emited)

-call conventions (use hashrefs instead of arrays?)

-standard (base component?) methods

-standard (base component?) events

-callback event declarations

-- 
David Davis
http://teknikill.net/


Re: Using POE::Wheel::SocketFactory

2004-02-10 Thread David Davis
You don't really need to mess with SocketFactory, you can use 
POE::Component::Client::TCP and write a filter for it to use, which is 
pretty easy. Then the ServerInput event would be called for every full 
message you receive in a data structure thats easy to use.

David

-- Original Message ---
From: "Jay Strauss" <[EMAIL PROTECTED]>
To: "David Davis" <[EMAIL PROTECTED]>
Sent: Tue, 10 Feb 2004 20:40:12 -0600
Subject: Re: Using POE::Wheel::SocketFactory

> There isn't one, I had to dissect the vendor supplied java client to
> determine the messages.  The way the conversation goes is:
> 
> poe> connected to socket
> server>responds, sending it's version
> poe> sends a clientid
> 
> Then in a infinite loop
> 
> server>sends (messageID, messageVersion, (list of data values))
> poe>reads (messageID, messageVersion), dispatch proper routine based 
> on messageID, proper routine> read data values based on the messageVersion;
> 
> end loop
> 
> Does this help?
> Jay
> - Original Message -
> From: "David Davis" <[EMAIL PROTECTED]>
> To: "Jay Strauss" <[EMAIL PROTECTED]>
> Sent: Tuesday, February 10, 2004 5:54 PM
> Subject: Re: Using POE::Wheel::SocketFactory
> 
> > where's the spec for this protocol?
> >
> > -- Original Message ---
> > From: "Jay Strauss" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Tue, 10 Feb 2004 09:13:18 -0600
> > Subject: Re: Using POE::Wheel::SocketFactory
> >
> > > Hi,
> > >
> > > I get what you say, with
> > >
> > > > You could build a list
> > > > of fields until @record == $record_length{$record[0]} or something.
> At
> > > > that point, you call whatever you've written to handle the record.
> > >
> > > I'm working on getting something to process the list in a timely
> > > fashion, but only once all the elements are there.
> > >
> > > Thanks
> > > Jay
> > --- End of Original Message ---
> >
> >
> >
--- End of Original Message ---



Re: Eksemple on http post instead of http get.

2004-02-05 Thread David Davis
When posting your 'request', the next parameter after the request is a tag 
to identify the request as you asked.
It comes in as $request_packet->[1]

I've modified my example, so take a look again at #3.

David

-- Original Message ---
From: "michael vernersen" <[EMAIL PROTECTED]>
To: "David Davis" <[EMAIL PROTECTED]>
Sent: Thu, 5 Feb 2004 07:43:07 +0100
Subject: Re: Eksemple on http post instead of http get.

> Hi David...
> 
> Thanks for you example , it helped me very much , and hopefully also 
> others.
> 
> I have one more questions.
> 
> How do i one more variable to 
> 
>  $kernel->post( "ua" => "request", "got_response", $request );
> 
> So i could use it in
> 
> sub got_response {
> 
> my ( $heap, $request_packet, $response_packet ) = @_[ HEAP, ARG0,
>  ARG1 ];
> 
> Tried to put on the fourth parameters , but it undef when  
> got_response is called...
> 
> I need a unique identifier so i know which post-job had finished
> 
> Thanks in advance
> 
> Regards , Michael Denmark.
> 
>  
> 
> - Original Message - 
> From: "David Davis" <[EMAIL PROTECTED]>
> Newsgroups: perl.poe
> To: "Michael" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Wednesday, February 04, 2004 7:52 PM
> Subject: Re: Eksemple on http post instead of http get.
> 
> > Sure!
> > I've done this before.
> > I'll make one and put it at the bottom as example 3.
> > 
> > David
> > -- Original Message ---
> > From: "Michael" <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Sent: Wed, 4 Feb 2004 17:23:58 +0100
> > Subject: Eksemple on http post instead of http get.
> > 
> > > Does anyone have an example on a http post instead
> > > of the http-get
> > > 
> > > in the following example...
> > > 
> > > http://poe.perl.org/?POE_Cookbook/Web_Client
> > > 
> > > Example 2: Multiple requests in a single session.
> > > 
> > > regards Michael.
> > --- End of Original Message ---
> >
--- End of Original Message ---



Re: Eksemple on http post instead of http get.

2004-02-04 Thread David Davis
Sure!
I've done this before.
I'll make one and put it at the bottom as example 3.

David
-- Original Message ---
From: "Michael" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Sent: Wed, 4 Feb 2004 17:23:58 +0100
Subject: Eksemple on http post instead of http get.

> Does anyone have an example on a http post instead
> of the http-get
> 
> in the following example...
> 
> http://poe.perl.org/?POE_Cookbook/Web_Client
> 
> Example 2: Multiple requests in a single session.
> 
> regards Michael.
--- End of Original Message ---