File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 11import asyncio
2+ import os
23import signal
34from collections .abc import Coroutine , Sequence
45from functools import partial
@@ -45,8 +46,9 @@ def __init__(
4546 def run (self , interactive : bool = True ):
4647 serve = asyncio .ensure_future (self .serve (interactive = interactive ))
4748
48- self ._loop .add_signal_handler (signal .SIGINT , serve .cancel )
49- self ._loop .add_signal_handler (signal .SIGTERM , serve .cancel )
49+ if os .name != "nt" :
50+ self ._loop .add_signal_handler (signal .SIGINT , serve .cancel )
51+ self ._loop .add_signal_handler (signal .SIGTERM , serve .cancel )
5052 self ._loop .run_until_complete (serve )
5153
5254 async def _run_initial_coros (self ):
Original file line number Diff line number Diff line change 11import getpass
22import os
3+ import sys
34from enum import StrEnum
45from logging import LogRecord
56from typing import TYPE_CHECKING , Any
@@ -30,13 +31,27 @@ def _configure_logger(
3031 graylog_env_fields : GraylogEnvFields | None = None ,
3132):
3233 logger .remove ()
34+
35+ try :
36+ sink = StdoutProxy (raw = True )
37+ except Exception :
38+ # e.g. prompt_toolkit.output.win32.NoConsoleScreenBufferError on windows
39+ # But it isn't exported from prompt_toolkit in a cross-platform way.
40+ sink = sys .stdout
41+
3342 logger .add (
34- sink = StdoutProxy ( raw = True ) , # type: ignore
43+ sink = sink , # type: ignore
3544 colorize = True ,
3645 format = format_record ,
3746 level = level or "INFO" ,
3847 )
3948
49+ if sink == sys .stdout :
50+ logger .warning (
51+ "Unable to use prompt_toolkit.patch_stdout.StdoutProxy "
52+ "as a logging sink; falling back to using sys.stdout"
53+ )
54+
4055 if graylog_endpoint is not None :
4156 static_fields = {
4257 "app_name" : "fastcs" ,
You can’t perform that action at this time.
0 commit comments