mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-05-14 19:17:32 +08:00
fix: guard LogInterceptor.flush() against OSError on Windows no-console setups (fixes #13554)
On Windows, when ComfyUI is launched without an attached console (e.g. from a desktop shortcut or detached process), sys.__stdout__ may point to an invalid console handle. Calling flush() on such a handle raises OSError: [Errno 22] Invalid argument, which propagates up through any code that calls print() and crashes every prompt execution. Wrap super().flush() in LogInterceptor.flush() with the same try/except (OSError, ValueError): pass pattern that is already used elsewhere in the codebase for exactly this scenario. A failed flush on a broken console handle just means the line isn't force-drained to that console; content still reaches log_file and the in-memory log buffers. Co-Authored-By: Octopus <liyuan851277048@icloud.com>
This commit is contained in:
parent
7385eb2800
commit
579a9263ea
@ -32,7 +32,10 @@ class LogInterceptor(io.TextIOWrapper):
|
||||
super().write(data)
|
||||
|
||||
def flush(self):
|
||||
super().flush()
|
||||
try:
|
||||
super().flush()
|
||||
except (OSError, ValueError):
|
||||
pass
|
||||
for cb in self._flush_callbacks:
|
||||
cb(self._logs_since_flush)
|
||||
self._logs_since_flush = []
|
||||
|
||||
Loading…
Reference in New Issue
Block a user