Attach the parent to the server thread, allowing the kill signal to trigger a graceful exit (#446)

This commit is contained in:
sabaimran 2023-08-17 02:36:10 +00:00 committed by GitHub
parent 3c58ab5fcb
commit 4e03dfea43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -11,8 +11,8 @@ from PySide6.QtCore import QThread
class ServerThread(QThread):
def __init__(self, start_server_func):
super(ServerThread, self).__init__()
def __init__(self, start_server_func, parent=None):
super(ServerThread, self).__init__(parent)
self.start_server_func = start_server_func
def __del__(self):

View file

@ -100,7 +100,7 @@ def run():
# Setup Server
initialize_server(args.config, args.regenerate, required=False)
configure_routes(app)
server = ServerThread(start_server_func=lambda: start_server(app, host=args.host, port=args.port))
server = ServerThread(start_server_func=lambda: start_server(app, host=args.host, port=args.port), parent=gui)
url = f"http://{args.host}:{args.port}"
logger.info(f"🌗 Khoj is running at {url}")