user-pic

http://openid.prettybrd.com/leedo

  • Commented on AnyEvent and Dancer: CondVars
    Sorry, I missed your reply to this. That likely isn't working because the timer is going out of scope and being canceled. You can fix this by assigning it to a scalar like this: my $app = sub { my...
  • Commented on AnyEvent and Dancer: CondVars
    This seems like the wrong approach, since it is going to block all other requests on Twiggy. If you really want to take advantage of Twiggy and AnyEvent you should avoid blocking with CondVars in your request handlers. Doing something...
Subscribe to feed Recent Actions from http://openid.prettybrd.com/leedo

  • James commented on AnyEvent and Dancer: CondVars

    Yes, it definitely seems the wrong approach, if you really want to wait on condvars, looks at the Coro server, Corona (where you have access to Coro::rouse_cb and Coro::rouse_wait which do what you want in your first example, but only blocking the current co-routine, not the whole app, like this:


    use Coro;
    use Dancer;

    get '/hello/:name' => sub {
    my $timer = AnyEvent->timer( after => 15, cb => Coro::rouse_cb );
    my ($status) = Coro::rouse_wait;
    return "Why, hello there " . params->{name};
    };

  • James commented on AnyEvent and Dancer: CondVars

    Scratch the last part of my previous comment, Dancer doesn't officially support delayed responses yet, so something like Coro seems to be the way to do it. Perhaps they'll allow routes to return coderefs instead of stringifying them when they do support that.

  • mstplbg commented on AnyEvent and Dancer: CondVars

    Hi!

    Sorry, I did not notice your comment earlier. I tried your example, but it does not work for me:

    >my $server = Twiggy::Server->new(
    host => '0.0.0.0',
    port => 5000
    );
    my $app = sub {
    my $env = shift;
    return sub {
    my $respond = shift;
    AnyEvent->timer(after => 1, cb => sub {
    $respond->([200, [], ["hello world!"]]);
    });
    };
    };
    $server->register_service($app);
    AnyEvent->condvar->recv

    When I try to access the server, I g…

Subscribe to feed Responses to Comments from http://openid.prettybrd.com/leedo

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.