Re: LWP::Parallel callback question
- From: John Bokma <john@xxxxxxxxxxxxxxx>
- Date: 28 Jan 2006 06:41:44 GMT
robert.bradley@xxxxxxxxx wrote:
> In the README I see the following:
>
> "You can define callback routines which will be called whenever a
> connection is established, is cut off, new data comes in or a request
> finishes. The subroutines can be global for all requests you
> registered, or different for every single request. "
>
> This sounds like it is possible to register individual requests with
> individual callbacks that get called when the request finishes. But,
> it seems the only kind of callback that gets called when a request
> finishes is global when we override the on_return method; it is called
> for all request that are registered. The individual callbacks for each
> request get invoked as data trickles back in, and I have to concatenate
> it. I don't see any way to register an individual callback for a given
> http request, that only gets called when the request finishes.
>
> Is there some way to get a different callback for each request to only
> be invoked once when the corresponding request completes? Or do I need
> to write some code to implement this behavior? I don't want to go off
> and re-invent the wheel in case I'm just missing the obvioius.
What I did some time ago is using each request I created (and registered
with pua) as a hash key, with the value an object having a callback
handler associated with the request, and then something like:
my $entries = $pua->wait();
for my $key ( keys %$entries ) {
my $response = $entries->{$key}->response;
my $action = $key2action{ $key };
$action->process( $response .... );
:
:
}
I have no idea if this is *the* way (I consider it quite clumsy), but
couldn't find a better solution in a short time, so I stuck with it.
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
I ploink googlegroups.com :-)
.
- Follow-Ups:
- Re: LWP::Parallel callback question
- From: robert . bradley
- Re: LWP::Parallel callback question
- References:
- LWP::Parallel callback question
- From: robert . bradley
- LWP::Parallel callback question
- Prev by Date: Crypt::SSLeay Installation Failure
- Next by Date: Re: Crypt::SSLeay Installation Failure
- Previous by thread: LWP::Parallel callback question
- Next by thread: Re: LWP::Parallel callback question
- Index(es):
Relevant Pages
|
|