#13908 closed enhancement (fixed)
Exit Sage gracefully upon SIGHUP
Reported by: | Jeroen Demeyer | Owned by: | Jeroen Demeyer |
---|---|---|---|
Priority: | major | Milestone: | sage-5.7 |
Component: | c_lib | Keywords: | |
Cc: | Merged in: | sage-5.7.beta2 | |
Authors: | Jeroen Demeyer | Reviewers: | Volker Braun |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | #13748, #13946 | Stopgaps: |
Description (last modified by )
Change the signal handling code to allow a graceful forced exit of Sage. "graceful" meaning that code is interrupted and the normal exit handlers are run. This graceful exit is not guaranteed to work, code which is currently not interruptible would not be exited.
This might be used by the doctesting framework to handle timeouts.
This patch also improves interrupt debugging:
- Different debug levels, set in a C file such that not everything needs to be recompiled when changing the debug level.
- Show time between signal received and exception raised.
Apply: 13908_terminate.patch
Attachments (2)
Change History (19)
comment:1 Changed 10 years ago by
Description: | modified (diff) |
---|---|
Summary: | Exit Sage gracefully upon SIGHUP → Exit Sage gracefully upon SIGHUP/SIGTERM |
comment:2 Changed 10 years ago by
Authors: | → Jeroen Demeyer |
---|---|
Status: | new → needs_review |
comment:3 Changed 10 years ago by
Dependencies: | #13748 → #13748, #13946 |
---|
comment:4 Changed 10 years ago by
Status: | needs_review → needs_work |
---|
comment:5 Changed 10 years ago by
Status: | needs_work → needs_review |
---|
comment:6 Changed 10 years ago by
Reviewers: | → Volker Braun |
---|---|
Status: | needs_review → positive_review |
comment:7 Changed 10 years ago by
Milestone: | sage-5.6 → sage-5.7 |
---|
comment:9 Changed 10 years ago by
Summary: | Exit Sage gracefully upon SIGHUP/SIGTERM → Exit Sage gracefully upon SIGHUP |
---|
Since the main motivation is to have some way of gracefully terminating Sage, I'm handling only SIGHUP
now, not SIGTERM
.
comment:10 Changed 10 years ago by
Description: | modified (diff) |
---|
Changed 10 years ago by
Attachment: | 13908_no_SIGTERM.patch added |
---|
Changed 10 years ago by
Attachment: | 13908_terminate.patch added |
---|
comment:11 Changed 10 years ago by
Description: | modified (diff) |
---|
comment:12 Changed 10 years ago by
Status: | needs_work → needs_review |
---|
comment:13 Changed 10 years ago by
Status: | needs_review → positive_review |
---|
Hmm I didn't see any discussion on sage-devel about SIGTERM but getting started with just catching SIGHUP is fine, too.
comment:14 Changed 10 years ago by
For the SIGTERM problem, see https://groups.google.com/forum/?fromgroups#!search/sage-devel$2013908/sage-devel/5BfDSSdN5qw/AcWANg5v2KwJ
comment:15 Changed 10 years ago by
Merged in: | → sage-5.7.beta2 |
---|---|
Resolution: | → fixed |
Status: | positive_review → closed |
comment:16 follow-up: 17 Changed 10 years ago by
I was running a moinmoin wiki with sage. With this patch applied, that doesn't work anymore because of the new interruption handling in sage.ext._init_csage
:
When running the wiki using
$ sage wikiserver.py
and importing sage.all.*
therein, I get the following error:
from sage.all import * File "/home/stumpc5/progs/sage-5.7/devel/sage-main/build/sage/all.py", line 59, in <module> _init_csage() File "c_lib.pyx", line 41, in sage.ext.c_lib._init_csage (sage/ext/c_lib.c:569) ValueError: signal only works in main thread
The issue seems to be solved when I comment out the signal in _init_csage
.
Question: Is there a (reasonable and finite) way to fix this issue properly? Can something serious go wrong if I comment these lines out?
Thanks, Christian
comment:17 Changed 10 years ago by
Replying to stumpc5:
Can something serious go wrong if I comment these lines out?
Not very serious. Interrupt handling might be a bit messed up, in particular some interrupts (CTRL-C) might be seen twice: once by the default Python handler (raise KeyboardInterrupt
) and once by the special Sage handler (written in C).
The line
signal.signal(signal.SIGINT, sage_python_check_interrupt)
is mainly used to ensure that only the Sage signal handler is used.
But this will certainly have no consequences beyond interrupt handling.
Sounds good to me.