dannoura has asked for the wisdom of the Perl Monks concerning the following question:
hi,
I'm trying to create a module with POE. The problem is that as far as I can tell the script doesn't reach the _ready state. Relevant parts of the code are below.
package ParallelDownloader; use strict; use Carp; use POE qw(Component::Client::HTTP); sub new { my ($class, $requests)=@_; my $self={requests=>$requests}; return bless $self, $class; } sub go { my $self=shift; POE::Component::Client::HTTP->spawn(Alias => 'ua'); POE::Session->create( inline_states => { _start => \&_initialize_session, ready => \&_ready, download => \&_download, got_response => \&_got_response }, heap => {TODO => $self->{requests}} ); $poe_kernel->run(); return _finished(); } sub _initialize_session { my $kernel = $_[KERNEL]; print "at init\n"; $kernel->yield("_ready"); } sub _ready { my $kernel=$_[KERNEL]; my $heap=$_[HEAP]; print "at ready\n"; return unless (@{$heap->{TO_GET}}=splice @{$heap->{TODO}}, 0, 5 +); $kernel->yield("_download"); }
-----------------------------------
Any comments about coding style are welcome.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Creating a module with POE
by johnnywang (Priest) on May 13, 2005 at 20:51 UTC | |
by dannoura (Pilgrim) on May 13, 2005 at 21:05 UTC | |
|
Re: Creating a module with POE
by rcaputo (Chaplain) on Jun 10, 2005 at 21:15 UTC |