Do I need Async::Interrupt ?

Marc Lehmann schmorp at schmorp.de
Sat Mar 10 18:42:08 CET 2012


On Sat, Mar 10, 2012 at 05:59:43PM +0100, Zsbán Ambrus <ambrus at math.bme.hu> wrote:
> AnyEvent::Loop.  The documentation does not mention whether it handles
> signals in a safe or unsafe way.  The AnyEvent docs say "you cannot do
> race-free signal handling in perl", so I think this means pure-perl

AnyEvent::Loop uses AnyEvent's signal code (I would have hoped that would
have been obvious :), and is therefore safe but racy (causing delays)
without Async::Interrupt, and safe and non-racy with it available.

> AnyEvent::Loop can not do race-free signal handling without
> Async::Interrupt.

Not at the moment - it could do unsafe but race-free, but nobody really
wants that.

> But now you say "often", so I'm unsure: maybe that sentence only means
> you cannot tack race-free signal handling from pure-perl to an existing
> event loop that does not handle signals, but there is some way to have
> race-free signal handling if you are writing the loop.

There is no known way to have race-free but safe signal handling in
pure perl. Pure perl gives you the choice between racy/unsafe and
non-racy/safe, basically.

> Thus, I'd like you to clarify how signal watchers work with
> AnyEvent::Loop, that is, that they use the MAX_SIGNAL_LATENCY wakeup
> mechanism to catch signals missed because of a race.

They do.

> It would be nice if you added a statement to this effect to the
> documentation as well, either in the AnyEvent::Loop doc or the AnyEvent
> doc section about signal races.

Hmm, what exactly? AnyEvent already mentions that you can install
Async::Interrupt to avoid these problems, and that without it, perl-based
event loops will be racy.

As far as AnyEvent is concerned, AnyEvent::Loop doesn't do signal handling
itself, because the code already exists in AnyEvent.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the anyevent mailing list