Inconsistency WAS Re: Running tests in background

Felipe Gasper felipe at felipegasper.com
Wed Jun 30 17:47:26 CEST 2021


> On Jun 8, 2021, at 9:19 AM, Felipe Gasper <felipe at felipegasper.com> wrote:
> 
> 
>> On Jun 8, 2021, at 2:37 AM, Marc Lehmann <schmorp at schmorp.de> wrote:
>> 
>> On Mon, Jun 07, 2021 at 12:50:01PM -0400, Felipe Gasper <felipe at felipegasper.com> wrote:
>>> 	Would you consider using SIGUSR1 instead of SIGINT in the AE test suite?
>> 
>> If there is a good reason to...
>> 
>>> 	We recently switched our test suite to run tests in a shell background. This caused AE’s test suite to fail on 02_signal.t, which we eventually realized was because the shell sets SIGINT to ignore, which Perl represents by saying that $SIG{INT} is 'IGNORE', which causes AnyEvent->signal() to be a no-op.
>> 
>> I will have to think about that. Of course, changing to SIGUSR1 does
>> nothing but work around the intricacies of your test environment, and
>> using USR1 will not realyl do anything, as that will then break with
>> another person's test script. Maybe AnyEvent should treat ignored signals
>> as it does default signals, but probably not.
>> 
>> Does the problem still perisst when you also instakl Async::Interrupt?
> 
> No, actually.
> 
> In fact, another pain point of mine with AE--the fact that a %SIG value of 'DEFAULT' is treated differently from undef/empty--also goes away with that module.
> 
> Is the intent that AnyEvent behave (as much as reasonably possible) the same with or without Async::Interrupt? If so--and assuming that Async::Interrupt’s behaviour is considered the more ideal--that would seem to make a case for treating 'DEFAULT' and 'IGNORE' %SIG values the same as undef/empty.
> 
> Notably: the problem also goes away when I switch to EV as the backend rather than AnyEvent::Loop.
> 
> A bit more alarmingly, though, EV and AE::Loop/Async::Interrupt will both clobber existing, non-default/ignore signal handlers, which plain AE::Loop will not do:
> 
> # EV:
> perl -Mstrict -w -MAnyEvent -e '$SIG{USR1} = sub {}; my $cv = AE::cv(); my $s = AE::signal( q/USR1/, $cv ); kill q/USR1/, $$; $cv->recv()'
> 
> # Async::Interrupt:
> perl -Mstrict -w -MAnyEvent::Loop -e '$SIG{USR1} = sub {}; my $cv = AE::cv(); my $s = AE::signal( q/USR1/, $cv ); kill q/USR1/, $$; $cv->recv()'
> 
> # Hangs:
> perl -Mstrict -w -MAnyEvent::Loop -e '$SIG{USR1} = sub {}; my $cv = AE::cv(); $AnyEvent::Base::HAVE_ASYNC_INTERRUPT = 0; my $s = AE::signal( q/USR1/, $cv ); kill q/USR1/, $$; $cv->recv()'

Any thoughts on this, Marc?

I assume that AnyEvent intends for its default behaviour to mimic, as best as possible, its behaviour when EV or Async::Interrupt are available. That being the case, would it not be sensible to make the above examples all work the same way?

Thank you!

cheers,
-Felipe



More information about the anyevent mailing list