Event-polling after a fork

Marc Lehmann schmorp at schmorp.de
Tue Feb 25 16:55:52 CET 2020

On Tue, Feb 25, 2020 at 07:27:59AM -0500, Felipe Gasper <felipe at felipegasper.com> wrote:
> This appears to be Mojo::IOLoop’s solution to this problem.

It might appear so to you, but it clearly doesn't. For one thing, it's
only one event loop, and AnyEvent of course has to work for all of
them. But it also doesn't handle any of the actual issues you run into
- sure, you can reset the loop, but how does that handle the resulting
breakage when watchers silently stop working for example? In code that
you have never seen because it was added after you wrote your program for
example? And lastly, it doesn't solve any of the problems that fork brings
with it.

And note that it relies on EV to do the limited work it does, and as far
as I know, EV is (I think) the only event loop that even attempts to do
soemthing sensible (e.g. allow you to remove watchers after a fork - with
other event loops this might result in watchers in both parent and child
becoming disabled for example. or worse).

> Would it be feasible to do something similar in AnyEvent? Most of AE’s event loop backends seem to be part of the distribution anyway, so whichever loops don’t add reset() could simply throw.

Well, first of all, it doesn't actually seem to solve an actual
problem. And most importantly, if you rely on something like that in a
specific event loop, you can just use that specific event loop - the point
of AnyEvent is to make event loops generically usable by programmers,
which is a much bigger group than group that controls a specific program
(think CPAN modules). An option that breaks this while pretendinfg to be
generic makes little sense - just use the event loop you think solves your
problems directly then, and deal with the issues cleanly.

                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