Skip Menu |

This queue is for tickets about the POE CPAN distribution.

Report information
The Basics
Id: 38587
Status: rejected
Priority: 0/
Queue: POE

People
Owner: Nobody in particular
Requestors: arrenlex [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: POE::Session doesn't allow sessions without _start
Date: Tue, 19 Aug 2008 10:35:08 -0600
To: bug-POE [...] rt.cpan.org
From: "Arren Lex" <arrenlex [...] gmail.com>
I have a session which models a task with many parts. The job object is created and processes its arguments, then creates the session and returns its ID, which the job manager uses to keep track of its properties (client, ip, etc.) and send events to it in some cases. This session will then do nothing until it receives a next_task event from the job manager from a callback. When it receives a next_task, it will complete the next part of the job and issue a 'ready' event to the job manager signal the part's completion. There is nothing for the job to do when it starts up -- I only need to make callbacks and save the ID, and then the session picks its nose waiting for a next_task. There is nothing for a _start session to do, but POE::Session enforces a _start event so I'm having to make stupid workarounds like _start => sub {}; Is it possible to remove this enforcement or turn it into a warning?
On Tue Aug 19 12:35:40 2008, arrenlex@gmail.com wrote: Show quoted text
> I have a session which models a task with many parts. The job object > is created and processes its arguments, then creates the session and > returns its ID, which the job manager uses to keep track of its > properties (client, ip, etc.) and send events to it in some cases. > This session will then do nothing until it receives a next_task event > from the job manager from a callback. When it receives a next_task, it > will complete the next part of the job and issue a 'ready' event to > the job manager signal the part's completion. > > There is nothing for the job to do when it starts up -- I only need to > make callbacks and save the ID, and then the session picks its nose > waiting for a next_task. There is nothing for a _start session to do, > but POE::Session enforces a _start event so I'm having to make stupid > workarounds like _start => sub {}; > > Is it possible to remove this enforcement or turn it into a warning?
Hello. Can you please provide a test case for the behavior you want? It need not work with POE in its current state, but it would help me understand what you're asking for. I'm confused because the session, having been created without work, would merely be garbage collected immediately upon the next POE dispatch cycle. That is, sessions must have something to do in order to prevent their destruction. Even if they only set themselves an alias... which is what I usually do from _start: package Manager; sub new { my ($class, $etc) = @_; my $self = bless { %$etc }, $class; POE::Session->create( object_states => [ $self => { _start => "_poe_start", shutdown => "_poe_shutdown", }, ], ); return $self; } sub _poe_start { $_[KERNEL]->alias_set("$_[OBJECT]"); } sub _poe_shutdown { $_[KERNEL]->alias_remove("$_[OBJECT]"); } In the above case, the outer management object can invoke the session by post() or call() to its stringified $self: sub manager_method { my ($self, @etc) = @_; $poe_kernel->call("$self", "some_event", @etc); } And to kill off the session at object destruction time: sub DESTROY { my $self = shift; $poe_kernel->call("$self", "shutdown"); } So you see, I don't know how you're bypassing the need for something in the _start handler. An example or test case should help me understand what you're trying to do. Thank you.
No response in over a year.