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]
name = "textual-serve"
version = "1.0.1"
version = "1.0.2"
description = "Turn your Textual TUIs in to web applications"
authors = [
{ name = "Will McGugan", email = "will@textualize.io" }

View File

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