AnyEvent recursive blocking wait with Plack

Dirk Koopman djk at tobit.co.uk
Thu Mar 8 00:28:12 CET 2012


On 07/03/12 20:23, Marc Lehmann wrote:
> On Tue, Mar 06, 2012 at 04:59:45PM -0800, Mike Schilli<anyevent at perlmeister.com>  wrote:
>> I'm hitting the 'recursive blocking wait' limitation in AnyEvent and
>> wonder how to work around it.
>
> I can't quite grok Plack::Handler::AnyEvent::HTTPD, but maybe it supports
> returning a code reference for just that reason?
>
> I.e. instead of returning data, you might be able to do this:
>
>     sub request {
>        sub {
>           my $respond = shift;
>           my $w; $w = AE::timer 5, 0, sub {
>           undef $w;
>              $respond->("go away, time is up");
>           };
>        }
>     }
>
> At least, this code in the module seems to suggest that:
>
>      my $res = Plack::Util::run_app($self->{app}, $env);
>      ...
>      ref $res eq 'CODE' ? $res->($respond) : $respond->($res);
>
> If that is true, then more or less the only thing that is supported in the
> requets callback is returning the code reference, and the code reference then
> gets a continuation object.
>
> I don't know if this is supported, or if other plack handlers support
> this, and I don't know whether this handler really works concurrently, but
> at least it looks as if some effort has been made to achieve that.
>
> (I hope it gets clear from the above that I really don't know nothing
> about Plack).
>

Then you should probably look at http://plackperl.org/. On there you 
will find a (old) Coro backend: https://github.com/miyagawa/Corona and a 
(more modern) EV based one: https://github.com/stash/Feersum.

One wonders how they work? Is it simply that they are "the backend" and 
therefore a Plack "request" effectively is an RPC call and thus an "event"?

Dirk



More information about the anyevent mailing list