windows fix

This commit is contained in:
Will McGugan
2024-06-19 16:14:43 +01:00
parent 9ec4d60615
commit 702960dd46
2 changed files with 9 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
[project] [project]
name = "textual-serve" name = "textual-serve"
version = "1.0.1" version = "1.0.2"
description = "Turn your Textual TUIs in to web applications" description = "Turn your Textual TUIs in to web applications"
authors = [ authors = [
{ name = "Will McGugan", email = "will@textualize.io" } { name = "Will McGugan", email = "will@textualize.io" }

View File

@@ -6,6 +6,7 @@ import logging
import os import os
from pathlib import Path from pathlib import Path
import signal import signal
import sys
from typing import Any from typing import Any
@@ -32,6 +33,9 @@ LOGO = r"""[bold magenta]___ ____ _ _ ___ _ _ ____ _ ____ ____ ____ _ _
""".replace("VVVVV", f"v{version('textual-serve')}") """.replace("VVVVV", f"v{version('textual-serve')}")
WINDOWS = sys.platform == "WINDOWS"
class LogHighlighter(RegexHighlighter): class LogHighlighter(RegexHighlighter):
base_style = "repr." base_style = "repr."
highlights = [ highlights = [
@@ -173,15 +177,16 @@ class Server:
self.initialize_logging() self.initialize_logging()
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
loop.add_signal_handler(signal.SIGINT, self.request_exit) if not WINDOWS:
loop.add_signal_handler(signal.SIGTERM, self.request_exit) loop.add_signal_handler(signal.SIGINT, self.request_exit)
loop.add_signal_handler(signal.SIGTERM, self.request_exit)
if self.debug: if self.debug:
log.info("Running in debug mode. You may use textual dev tools.") log.info("Running in debug mode. You may use textual dev tools.")
web.run_app( web.run_app(
self._make_app(), self._make_app(),
host=self.host, host=self.host,
port=self.port, port=self.port,
handle_signals=False, handle_signals=WINDOWS,
loop=loop, loop=loop,
print=lambda *args: None, print=lambda *args: None,
) )