Client stopping stops now also the mpv process
This commit is contained in:
parent
f7a21c6133
commit
631a408ada
4 changed files with 25 additions and 9 deletions
|
@ -48,6 +48,7 @@ from typing import Optional
|
|||
import qrcode
|
||||
|
||||
import socketio
|
||||
import engineio
|
||||
from PIL import Image
|
||||
|
||||
from . import jsonencoder
|
||||
|
@ -375,8 +376,11 @@ async def handle_request_config(data: dict[str, Any]) -> None:
|
|||
await sio.emit("config", {"source": data["source"], "config": config})
|
||||
|
||||
|
||||
def terminate(*args):
|
||||
print("OOPS")
|
||||
def signal_handler():
|
||||
engineio.async_client.async_signal_handler()
|
||||
if state.current_source is not None:
|
||||
if state.current_source.player is not None:
|
||||
state.current_source.player.kill()
|
||||
|
||||
|
||||
async def start_client(config: dict[str, Any]) -> None:
|
||||
|
@ -408,8 +412,18 @@ async def start_client(config: dict[str, Any]) -> None:
|
|||
state.config["key"] = ""
|
||||
|
||||
await sio.connect(state.config["server"])
|
||||
|
||||
asyncio.get_event_loop().add_signal_handler(signal.SIGINT, signal_handler)
|
||||
asyncio.get_event_loop().add_signal_handler(signal.SIGTERM, signal_handler)
|
||||
|
||||
try:
|
||||
await sio.wait()
|
||||
print("exit")
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
finally:
|
||||
if state.current_source is not None:
|
||||
if state.current_source.player is not None:
|
||||
state.current_source.player.kill()
|
||||
|
||||
|
||||
def create_async_and_start_client(config):
|
||||
|
|
|
@ -322,10 +322,10 @@ class SyngGui(customtkinter.CTk):
|
|||
)
|
||||
self.startbutton.pack(side="right")
|
||||
|
||||
startserverbutton = customtkinter.CTkButton(
|
||||
fileframe, text="Start Server", command=self.start_server
|
||||
)
|
||||
startserverbutton.pack(side="right")
|
||||
# startserverbutton = customtkinter.CTkButton(
|
||||
# fileframe, text="Start Server", command=self.start_server
|
||||
# )
|
||||
# startserverbutton.pack(side="right")
|
||||
|
||||
open_web_button = customtkinter.CTkButton(
|
||||
fileframe, text="Open Web", command=self.open_web
|
||||
|
|
|
@ -18,7 +18,8 @@ class FilesSource(FileBasedSource):
|
|||
|
||||
source_name = "files"
|
||||
config_schema = FileBasedSource.config_schema | {
|
||||
"dir": (str, "Directory to index", ".")
|
||||
"dir": (str, "Directory to index", "."),
|
||||
"index_file": (str, "Index file", "files-index"),
|
||||
}
|
||||
|
||||
def __init__(self, config: dict[str, Any]):
|
||||
|
|
|
@ -41,6 +41,7 @@ class S3Source(FileBasedSource):
|
|||
"secure": (bool, "Use SSL", True),
|
||||
"bucket": (str, "Bucket of the s3", ""),
|
||||
"tmp_dir": (str, "Folder for\ntemporary download", "/tmp/syng"),
|
||||
"index_file": (str, "Index file", "s3-index"),
|
||||
}
|
||||
|
||||
def __init__(self, config: dict[str, Any]):
|
||||
|
|
Loading…
Add table
Reference in a new issue