Sfoglia il codice sorgente

fix: wrap old handler

master
lanvent 1 anno fa
parent
commit
8193ecf5f6
1 ha cambiato i file con 9 aggiunte e 5 eliminazioni
  1. +9
    -5
      app.py

+ 9
- 5
app.py Vedi File

@@ -8,18 +8,22 @@ from plugins import *
import signal
import sys

def sigterm_handler(_signo, _stack_frame):
conf().save_user_datas()
sys.exit(0)
def sigterm_handler_wrap(_signo):
old_handler = signal.getsignal(_signo)
def func(_signo, _stack_frame):
logger.info("signal {} received, exiting...".format(_signo))
conf().save_user_datas()
return old_handler(_signo, _stack_frame)
signal.signal(_signo, func)

def run():
try:
# load config
load_config()
# ctrl + c
signal.signal(signal.SIGINT, sigterm_handler)
sigterm_handler_wrap(signal.SIGINT)
# kill signal
signal.signal(signal.SIGTERM, sigterm_handler)
sigterm_handler_wrap(signal.SIGTERM)

# create channel
channel_name=conf().get('channel_type', 'wx')


Loading…
Annulla
Salva