diff --git a/pyproject.toml b/pyproject.toml index 9c32b4e..d37eaab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" } diff --git a/src/textual_serve/server.py b/src/textual_serve/server.py index c6cfa2b..d9caecb 100644 --- a/src/textual_serve/server.py +++ b/src/textual_serve/server.py @@ -6,6 +6,7 @@ import os from pathlib import Path import signal +import sys from typing import Any @@ -32,6 +33,9 @@ """.replace("VVVVV", f"v{version('textual-serve')}") +WINDOWS = sys.platform == "WINDOWS" + + class LogHighlighter(RegexHighlighter): base_style = "repr." highlights = [ @@ -173,15 +177,16 @@ def serve(self, debug: bool = False) -> None: 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, )