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 random
|
||||
import requests
|
||||
import signal
|
||||
import time
|
||||
|
||||
from denylist import 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():
|
||||
res = None
|
||||
|
@ -67,7 +75,6 @@ with Live(
|
|||
time.sleep(0.05)
|
||||
time.sleep(30)
|
||||
first_it = False
|
||||
except KeyboardInterrupt:
|
||||
# Ctrl-C reloads, kill me with Ctrl-\
|
||||
except Usr1Interrupt:
|
||||
first_it = True
|
||||
pass
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#!/usr/bin/env bash
|
||||
kill -INT $(pgrep -f quotes.py)
|
||||
kill -USR1 $(pgrep -f quotes.py)
|
||||
|
|
Loading…
Reference in a new issue