mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
catch SIGTERM, and respond more quickly
This commit is contained in:
parent
7d8818f855
commit
f22aa4c199
1 changed files with 6 additions and 2 deletions
|
@ -799,9 +799,10 @@ title="%s" %s>%s</button>""" % (
|
|||
##########################################################################
|
||||
|
||||
def setupSignals(self) -> None:
|
||||
signal.signal(signal.SIGINT, self.onSigInt)
|
||||
signal.signal(signal.SIGINT, self.onUnixSignal)
|
||||
signal.signal(signal.SIGTERM, self.onUnixSignal)
|
||||
|
||||
def onSigInt(self, signum, frame):
|
||||
def onUnixSignal(self, signum, frame):
|
||||
# schedule a rollback & quit
|
||||
def quit():
|
||||
self.col.db.rollback()
|
||||
|
@ -1227,6 +1228,9 @@ Difference to correct time: %s."""
|
|||
self.progress.timer(10 * 60 * 1000, self.onRefreshTimer, True)
|
||||
# check media sync every 5 minutes
|
||||
self.progress.timer(5 * 60 * 1000, self.on_autosync_timer, True)
|
||||
# ensure Python interpreter runs at least once per second, so that
|
||||
# SIGINT/SIGTERM is processed without a long delay
|
||||
self.progress.timer(1000, lambda: None, True, False)
|
||||
|
||||
def onRefreshTimer(self):
|
||||
if self.state == "deckBrowser":
|
||||
|
|
Loading…
Reference in a new issue