Skip to content

Commit

Permalink
don't add signal handler on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Aug 22, 2023
1 parent bc1af58 commit f3c24db
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/textual/drivers/web_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import asyncio
import json
import os
import platform
import selectors
import signal
import sys
Expand All @@ -28,6 +29,8 @@
from ..geometry import Size
from ._byte_stream import ByteStream

WINDOWS = platform.system() == "Windows"


class WebDriver(Driver):
"""A headless driver that may be run remotely."""
Expand Down Expand Up @@ -95,8 +98,9 @@ def do_exit() -> None:
self._app._post_message(messages.ExitApp()), loop=loop
)

for _signal in (signal.SIGINT, signal.SIGTERM):
loop.add_signal_handler(_signal, do_exit)
if not WINDOWS:
for _signal in (signal.SIGINT, signal.SIGTERM):
loop.add_signal_handler(_signal, do_exit)

self._write(b"__GANGLION__\n")

Expand Down Expand Up @@ -185,3 +189,7 @@ def on_meta(self, packet_type: str, payload: dict) -> None:
self._app._post_message(event),
loop=self._loop,
)
elif packet_type == "quit":
asyncio.run_coroutine_threadsafe(
self._app._post_message(messages.ExitApp()), loop=self._loop
)

0 comments on commit f3c24db

Please sign in to comment.