Re: Is POE thread safe?

2009-05-23 Thread howard chen
Hello, On Sun, May 24, 2009 at 4:00 AM, Rocco Caputo wrote: > In this case, response_handler() is always synchronized. > Thanks for reply. "In this case" do you mean in POE::Component::Client::HTTP or in generic POE handler? For example, if I create session this way... for (1..10) { POE:

Is POE thread safe?

2009-05-23 Thread howard chen
Hey, For example, in POE::Component::Client::HTTP (http://search.cpan.org/~rcaputo/POE-Component-Client-HTTP-0.88/lib/POE/Component/Client/HTTP.pm ), the default max_per_host is 4. So is it always safe to do the following? (i.e. is the handler "response_handler" synchronized?) my $obj = MyClas

Move from one handler to another (manually)

2009-05-01 Thread howard chen
Hello, In POE, how to move from one handler (manually) to another handler? E.g. http://search.cpan.org/dist/POE-Component-Client-NNTP/lib/POE/Component/Client/NNTP.pm Inside the "nntp_211" method, I want to force jump to the "_shutdown" method? Thanks.

Re: Use of POE within a module

2009-04-28 Thread howard chen
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 sur

Use of POE within a module

2009-04-28 Thread howard chen
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_socket

Re: Why POE is slower then Python - Twisted ... quite a lot?

2009-03-25 Thread howard chen
Hi, On Wed, Mar 25, 2009 at 11:14 PM, Chris Prather wrote: > > That's a big supposition to make: > Please understand that my original email is comparing 37 vs 18 seconds difference (i.e. 200% speedup), so I don't really care about the startup/shutdown time since the difference is such obvious.

Re: Why POE is slower then Python - Twisted ... quite a lot?

2009-03-25 Thread howard chen
Hello, On Wed, Mar 25, 2009 at 4:10 AM, Rocco Caputo wrote: > > time(1) includes Perl & Python startup/shutdown time, which may be > significant. > Suppose the difference is negligible. > Your times seem to be wall clock based, which can vary based on system load, > network conditions, and so

Why POE is slower then Python - Twisted ... quite a lot?

2009-03-23 Thread howard chen
I have 2 simple scripts which connect to NNTP server to fetch 100 articles (no writing to local disk) in order to test the performance of two frameworks. I have found Twisted is faster by at least 2 times which make me surprised. I know it is not fair to compare two frameworks by this simple test

Writing a simple HTTP spider using POE

2009-03-17 Thread howard chen
Hello, I am new to POE and event/driven programming, I hope you guy can give some adivce for me. Now, I am writing a simple HTTP spider, which based the code from: http://poe.perl.org/?POE_Cookbook/Web_Client #= use HTTP::Request::Common qw(GET POST); use POE qw(C