#13311: alarm() doesn't work for Cython code
------------------------------------------+---------------------------------
Reporter: alexc | Owner: jdemeyer
Type: defect | Status: needs_review
Priority: major | Milestone: sage-5.10
Component: c_lib | Resolution:
Keywords: alarm signal interrupt | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Jeroen Demeyer | Merged in:
Dependencies: #14029 | Stopgaps:
------------------------------------------+---------------------------------
Description changed by jdemeyer:
Old description:
> The following code does not work as intended (I imagine), i.e. it does
> not interrupt the computation after 3 seconds.
>
> {{{
> #!python
>
> #!/usr/bin/python -tt
>
> from sage.all import *
> import time
>
> def main():
> alarm(3)
> try:
> EllipticCurve([123456, 789011]).rank()
> #time.sleep(5) #code works as intended if the above command is
> replaced with this
> except KeyboardInterrupt:
> print 'Took too long'
>
> # This is the standard boilerplate that calls the main() function.
> if __name__ == '__main__':
> main()
> }}}
New description:
The following code does not work as intended (I imagine), i.e. it does not
interrupt the computation after 3 seconds.
{{{
#!python
#!/usr/bin/python -tt
from sage.all import *
import time
def main():
alarm(3)
try:
EllipticCurve([123456, 789011]).rank()
#time.sleep(5) #code works as intended if the above command is
replaced with this
except KeyboardInterrupt:
print 'Took too long'
# This is the standard boilerplate that calls the main() function.
if __name__ == '__main__':
main()
}}}
The problem is that the `c_lib` interrupt handling code doesn't treat the
`SIGALRM` signal, this is fixed in the attached patch. It also changes
some exception classes (instead of raising `RuntimeError` for every
signal). Another cool new feature is that `alarm()` now works with a
floating-point number of seconds.
'''Apply''' [attachment:13311_sigalrm.patch]
--
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13311#comment:11>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.