Clean-up Ctrl+C Shutdown (#4802)

This commit is contained in:
erew123 2023-12-05 05:16:16 +00:00 committed by GitHub
parent 0f828ea441
commit f786aa3caa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -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")

View File

@ -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'