Only gracefully handle SIGINT once

This commit is contained in:
jesopo 2018-12-03 19:46:15 +00:00
parent 50149523dd
commit 351a88bda6

View file

@ -6,6 +6,7 @@ from src import Config, ModuleManager, utils
"validate": utils.bool_or_none})
class Module(ModuleManager.BaseModule):
def on_load(self):
self._exited = False
signal.signal(signal.SIGINT, self.SIGINT)
signal.signal(signal.SIGUSR1, self.SIGUSR1)
@ -14,6 +15,10 @@ class Module(ModuleManager.BaseModule):
self.bot.trigger(lambda: self._kill(signum))
def _kill(self, signum):
if self._exited:
return
self._exited = True
self.events.on("signal.interrupt").call(signum=signum)
for server in self.bot.servers.values():