On Friday, December 23, 2016 at 7:58:11 AM UTC+1, Jeroen Demeyer wrote: > > On 2016-12-22 11:25, Jean-Pierre Flori wrote: > > Dear all, > > > > First question: Is there are fundamental differences btw using the > > cysignal alarm function and the one from the signal module? > > Depends what you mean with "fundamental". The internal implementation is > different. The main user-visible difference is that Python's alarm > requires an integer timeout, while cysignals accepts a floating-point > timeout. > > > Second question: Is there any reason to make AlarmInterrupt derive from > > KeyboardInterrupt? > > SIGALARM and SIGINT are different signals. > > I give you 3 reasons: > > 1. Historically, Sage has used KeyboardInterrupt for alarm(). So > deriving AlarmInterrupt from KeyboardInterrupt is backwards-compatible > with code catching KeyboardInterrupt for alarms. > > 2. Conceptually, KeyboardInterrupt and AlarmInterrupt are quite close. > They both originate from signals and can interrupt code in the middle of > a computation. > > 3. Since alarm() raises a sub-class of KeyboardInterrupt, alarm() > provides an easy way to test interrupt-handling of code. > > > And its troublesome when using sage pexpect interfaces as they eat > > KeyboardInterrupt (and so AlarmInterrupt). > > What do you mean, they "eat" KeyboardInterrupt? > They handle it themselves with a try/except clause. So if I raise an AlarmInterrupt which derives on KeyboardInterrupt, it gets caught and I don't really have control: the code in sage/expect.py does it thing and then I get back a KeyboardInterrupt (and not an AlarmInterrupt).
Maybe the code in sage/except.py should at least be modified not to modify the class of the exception. For the fact that it also does its own stuff before raising the error I could live with it but maybe we should also add an option to the except interface to directly raise the exception without trying anything. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.