AnyEvent recursive blocking wait with Plack

Dirk Koopman djk at tobit.co.uk
Thu Mar 8 13:02:03 CET 2012


On 08/03/12 06:14, Mike Schilli wrote:
> Say, my web app does a server-server-request. If I'm running it in
> Plack/apache/mod_perl, I need to use synchronous methods (LWP::UserAgent
> et al) and if I'm running in an event-based framework like
> AnyEvent::HTTPD, I need to use event-based methods (AnyEvent::HTTP et
> al).
>
> Plack does in fact report to the web app if it's running on a
> synchronous or
> asynchronous 'platform', but is there a standardized way to offer the
> same functionality in a portable way (rhetorical question, I know, but
> a man can dream).
>

Have a look at: https://github.com/miyagawa/Tatsumaki

Which shows an example of using Plack asynchronously, but as the README 
says:

PSGI COMPATIBILITY
     When "asynchronous" is declared in your application, you need a PSGI
     server backend that supports "psgi.streaming" response style. If your
     application does server push with "stream_write", you need a server 
that
     supports "psgi.nonblocking" (and "psgi.streaming") as well.

     Currently Tatsumaki asynchronous application is supposed to run on
     Twiggy, Feersum, Corona and POE::Component::Server::PSGI.

     If "asynchronous" is not used, your application is supposed to run in
     any PSGI standard environments, including blocking multiprocess
     environments like Starman or Starlet.

Twiggy uses AE, Corona uses Coro and Feersum uses EV.




More information about the anyevent mailing list