mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-10-01 01:26:03 -04:00
Clean-up Ctrl+C Shutdown (#4802)
This commit is contained in:
parent
0f828ea441
commit
f786aa3caa
@ -4,6 +4,7 @@ import hashlib
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import signal
|
||||
import site
|
||||
import subprocess
|
||||
import sys
|
||||
@ -27,6 +28,13 @@ else:
|
||||
flags = f"{' '.join([flag for flag in sys.argv[1:] if flag != '--update'])} {CMD_FLAGS}"
|
||||
|
||||
|
||||
def signal_handler(sig, frame):
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
|
||||
|
||||
def is_linux():
|
||||
return sys.platform.startswith("linux")
|
||||
|
||||
|
12
server.py
12
server.py
@ -21,6 +21,7 @@ matplotlib.use('Agg') # This fixes LaTeX rendering on some systems
|
||||
|
||||
import json
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
import time
|
||||
from functools import partial
|
||||
@ -55,6 +56,17 @@ from modules.models_settings import (
|
||||
from modules.utils import gradio
|
||||
|
||||
|
||||
def signal_handler(sig, frame):
|
||||
logger.info(f"Received Ctrl+C. Shutting down Text generation web UI gracefully")
|
||||
if 'interface' in shared.gradio:
|
||||
shared.gradio['interface'].close()
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
|
||||
|
||||
def create_interface():
|
||||
|
||||
title = 'Text generation web UI'
|
||||
|
Loading…
Reference in New Issue
Block a user