Re: LWP::Parallel callback question



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 :-)

.



Relevant Pages

  • LWP::Parallel callback question
    ... or different for every single request. ... individual callbacks that get called when the request finishes. ... it seems the only kind of callback that gets called when a request ... I don't see any way to register an individual callback for a given ...
    (comp.lang.perl.modules)
  • [3/4] Distributed storage. Algorithms.
    ... * GNU General Public License for more details. ... * This callback is invoked when node is removed from storage. ... * request processing. ... * This function reads or writes node's private data from underlying media. ...
    (Linux-Kernel)
  • Async callbacks with Global.asax
    ... ICallbackEventHandler and RaiseCallbackEvent) and a regular GET request ... And here is the page that handles the callback request. ... the callback handler in _Default page. ... includeStagesBeforeAsyncPoint = true, bool includeStagesAfterAsyncPoint ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Asynchronous socket operations and threadpool
    ... | 0 - You get the Socket.BeginRead callback, ... | an IOCP thread. ... You kick off the DB Request async, do as much more of the user request as ... An additional complication is that your socket is back in BeginRead mode so ...
    (microsoft.public.dotnet.framework)
  • RE: ObjectDataSource update using callback instead of postback
    ... As for ASP.NET script callback, its request is ... some normal postback data processing and events other than the script call ...
    (microsoft.public.dotnet.framework.aspnet)