unexpected _child(lose) for a detached session from _start
Hi POE fellows, I'm in the process of rewriting the backend of my POE::Component::Schedule to make the backend session independent of others session in the system. The point is that session is just backend stuff, so it should not fire _child events to the session from which the API may have been called. Also, the schedule session is a singleton that may be used by multiple session, so it has no reason for being attached to a particular session. To achieve that, I'm calling POE::Kernel-detach_myself in the _start handler of the session. POE does'nt fire _child(create) as I expected. However I also found out that POE still fires _child(lose). My opinion is that POE should not fire a _child(lose) event if the session is detached from its parent in the _start handler as a 'lose' without 'create'/'gain' is inconsistent. Also it would be better if 'detach = 1' was an argument to POE::Session-create(): it would make the 'not attached' particularity of this session more explicit for people reading the code. Here is a test case that shows the current flawed behavior (tested with POE 1.006, POE 1.280): use strict; use warnings; use Test::More tests = 7; use POE; my $_child_fired = 0; POE::Session-create( inline_states = { _start = sub { $_[KERNEL]-alias_set('First'); pass _start First; POE::Session-create( inline_states = { _start = sub { $_[KERNEL]-alias_set('Second'); pass _start Second; }, }, ); POE::Session-create( inline_states = { _start = sub { $_[KERNEL]-alias_set('Detached'); pass _start Detached; diag Detaching session 'Detached' from its parent; $_[KERNEL]-detach_myself; }, }, ); }, _child = sub { $_child_fired++; ok($_[KERNEL]-alias_list($_[ARG1]) ne 'Detached', $_[STATE]($_[ARG0]) fired for .$_[KERNEL]-alias_list($_[ARG1]-ID)); }, }, ); POE::Kernel-run(); pass _child not fired for session detached in _start unless $_child_fired != 2; pass Stopped; Olivier Mengué http://o.mengue.free.fr/
help with POE::Component::Client::HTTP
Hello all, I am using the POE::Component::Client::HTTP part of POE to call 4 URLs simultaneously. This works really well, except for the fact that there is either a 5 second lag or a 43 second lag from the last URL pulled. No matter what I set the keepalive or timeout too, it is always either 5 or 43 seconds (every once in a while 86 seconds, but that is about 1 out of a hundred times). I have tried to use the information from this URL to shut down the session after the last URL is pulled, but it never works. http://poe.perl.org/?Poe_faq/how_do_i_force_a_session_to_shut_down the calls i have tried are : shutdown(POE::Component::Client::HTTP); - it says i have too few arguments shutdown(POE::Component::Client::HTTP::*Kernel* ,POE::Component::Client::HTTP::*Session*); - nothing happens shutdown(POE::Component::Client::HTTP::*Kernel* ,POE::Component::Client::HTTP::*Session*,POE::Component::Client::HTTP::*Heap *); - it says i have too many arguements And I have used the code from example 2 on the following page for my URL pulls: http://poe.perl.org/?POE_Cookbook/Web_Client Any thoughts on why this could be happening? The software works superbly aside from this one glitch and I would hate to have to look yet again for another alternative to LWP. Thanks for any help! Aaron
Re: help with POE::Component::Client::HTTP
It appears that you're using Perl's built-in shutdown() function rather than the shutdown documented in POE::Component::Client::HTTP. Of course, I can't really tell without seeing your code, but that's what it looks like from the calls you've shown. Please look for shutdown in the POE::Component::Client::HTTP documentation. -- Rocco Caputo - rcap...@pobox.com On Nov 19, 2009, at 22:03, Aaron Goodmiller wrote: Hello all, I am using the POE::Component::Client::HTTP part of POE to call 4 URLs simultaneously. This works really well, except for the fact that there is either a 5 second lag or a 43 second lag from the last URL pulled. No matter what I set the keepalive or timeout too, it is always either 5 or 43 seconds (every once in a while 86 seconds, but that is about 1 out of a hundred times). I have tried to use the information from this URL to shut down the session after the last URL is pulled, but it never works. http://poe.perl.org/?Poe_faq/how_do_i_force_a_session_to_shut_down the calls i have tried are : shutdown(POE::Component::Client::HTTP); - it says i have too few arguments shutdown(POE::Component::Client::HTTP::*Kernel* ,POE::Component::Client::HTTP::*Session*); - nothing happens shutdown(POE::Component::Client::HTTP::*Kernel* ,POE ::Component ::Client::HTTP::*Session*,POE::Component::Client::HTTP::*Heap *); - it says i have too many arguements And I have used the code from example 2 on the following page for my URL pulls: http://poe.perl.org/?POE_Cookbook/Web_Client Any thoughts on why this could be happening? The software works superbly aside from this one glitch and I would hate to have to look yet again for another alternative to LWP. Thanks for any help! Aaron
Re: unexpected _child(lose) for a detached session from _start
Agreed, a _child(lose) before the _child(create) is bad. It should either be a _child(create)/_child(lose) pair, or nothing in this case. I'm tempted to go with nothing since it would be hard to fix the create/lose timing. Also the new(detached = 1) seems good, but I admit I haven't given it much though yet. Sometimes I change my mind after thinking about things too hard. If you haven't already, please submit this to bug-...@rt.cpan.org. I'm liable to forget about POE bugs, patches, tests, etc. if they're not in POE's bug tracker. Thank you again for all your help. -- Rocco Caputo - rcap...@pobox.com On Nov 19, 2009, at 14:00, Olivier Mengué wrote: Hi POE fellows, I'm in the process of rewriting the backend of my POE::Component::Schedule to make the backend session independent of others session in the system. The point is that session is just backend stuff, so it should not fire _child events to the session from which the API may have been called. Also, the schedule session is a singleton that may be used by multiple session, so it has no reason for being attached to a particular session. To achieve that, I'm calling POE::Kernel-detach_myself in the _start handler of the session. POE does'nt fire _child(create) as I expected. However I also found out that POE still fires _child(lose). My opinion is that POE should not fire a _child(lose) event if the session is detached from its parent in the _start handler as a 'lose' without 'create'/'gain' is inconsistent. Also it would be better if 'detach = 1' was an argument to POE::Session-create(): it would make the 'not attached' particularity of this session more explicit for people reading the code. Here is a test case that shows the current flawed behavior (tested with POE 1.006, POE 1.280): use strict; use warnings; use Test::More tests = 7; use POE; my $_child_fired = 0; POE::Session-create( inline_states = { _start = sub { $_[KERNEL]-alias_set('First'); pass _start First; POE::Session-create( inline_states = { _start = sub { $_[KERNEL]-alias_set('Second'); pass _start Second; }, }, ); POE::Session-create( inline_states = { _start = sub { $_[KERNEL]-alias_set('Detached'); pass _start Detached; diag Detaching session 'Detached' from its parent; $_[KERNEL]-detach_myself; }, }, ); }, _child = sub { $_child_fired++; ok($_[KERNEL]-alias_list($_[ARG1]) ne 'Detached', $_[STATE]($_[ARG0]) fired for .$_[KERNEL]-alias_list($_[ARG1]-ID)); }, }, ); POE::Kernel-run(); pass _child not fired for session detached in _start unless $_child_fired != 2; pass Stopped; Olivier Mengué http://o.mengue.free.fr/
Re: help with POE::Component::Client::HTTP
On 20.11.2009 04:03 Aaron Goodmiller wrote: I am using the POE::Component::Client::HTTP part of POE to call 4 URLs simultaneously. This works really well, except for the fact that there is either a 5 second lag or a 43 second lag from the last URL pulled. No matter what I set the keepalive or timeout too, it is always either 5 or 43 seconds (every once in a while 86 seconds, but that is about 1 out of a hundred times). I had a similar problem a few weeks ago (see the list archives) and came up with something like this within the loop over the URLs: if (@what_we_got_already == @urls) { # everything done $kernel-post(ua = 'shutdown' ); } hth -Michael