fix(windows): handle redirected stdout in _cprint fallback
Wraps _pt_print in try/except with a print() fallback. When a kanban worker's stdout is piped to a log file, prompt_toolkit raises NoConsoleScreenBufferError (Windows) or OSError (other) because there is no real console buffer. The fallback keeps worker output flowing instead of crashing.
This commit is contained in:
11
cli.py
11
cli.py
@@ -1785,7 +1785,16 @@ def _cprint(text: str):
|
|||||||
# direct prompt_toolkit print is safe and matches existing behavior
|
# direct prompt_toolkit print is safe and matches existing behavior
|
||||||
# (spinner frames, streamed tokens, tool activity prefixes, …).
|
# (spinner frames, streamed tokens, tool activity prefixes, …).
|
||||||
if app is None or not getattr(app, "_is_running", False):
|
if app is None or not getattr(app, "_is_running", False):
|
||||||
_pt_print(_PT_ANSI(text))
|
try:
|
||||||
|
_pt_print(_PT_ANSI(text))
|
||||||
|
except Exception:
|
||||||
|
# Fallback when stdout is not a real console (e.g. subprocess
|
||||||
|
# worker logging to a file). prompt_toolkit raises
|
||||||
|
# NoConsoleScreenBufferError (Windows) or OSError (other).
|
||||||
|
try:
|
||||||
|
print(text)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user