Force show last quote with SIGUSR1 instead of SIGINT
This commit is contained in:
parent
dd430dacac
commit
fcb880b741
2 changed files with 10 additions and 3 deletions
11
quotes.py
11
quotes.py
|
@ -7,11 +7,19 @@ from rich.text import Text
|
||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
import requests
|
import requests
|
||||||
|
import signal
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from denylist import get_deny_list
|
from denylist import get_deny_list
|
||||||
denylist = get_deny_list()
|
denylist = get_deny_list()
|
||||||
|
|
||||||
|
class Usr1Interrupt(Exception):
|
||||||
|
def __init__(self, message):
|
||||||
|
super().__init__(message)
|
||||||
|
|
||||||
|
def handle_sigusr1(sig, frame):
|
||||||
|
raise Usr1Interrupt("")
|
||||||
|
signal.signal(signal.SIGUSR1, handle_sigusr1)
|
||||||
|
|
||||||
def refresh_quotes():
|
def refresh_quotes():
|
||||||
res = None
|
res = None
|
||||||
|
@ -67,7 +75,6 @@ with Live(
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
time.sleep(30)
|
time.sleep(30)
|
||||||
first_it = False
|
first_it = False
|
||||||
except KeyboardInterrupt:
|
except Usr1Interrupt:
|
||||||
# Ctrl-C reloads, kill me with Ctrl-\
|
|
||||||
first_it = True
|
first_it = True
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
kill -INT $(pgrep -f quotes.py)
|
kill -USR1 $(pgrep -f quotes.py)
|
||||||
|
|
Loading…
Reference in a new issue