AS
This is almost certainly a known perl bug you are running into, andСсылку нужно прочитать, чтобы понять, что он так думает.
there is nothing AnyEvent can do about it (the problem is not the
random/unpredictable order, the problem is that perl corrupts data
structures). I wrote a blog post about this if you are interested about
the details:
http://blog.schmorp.de/2015-11-12-tidbits-why-coro-crashes-or-how-perl-6-deals-with-bugs.html
In short, adding a check does not work, as you will have to check
basically EVERY access in your program, as you can never be sure whether
your code is called duriung global destruction or not. It is simpler,
easier and much faster to just do your cleanup as normal, and then call
_exit or some similar function.