-
-
Notifications
You must be signed in to change notification settings - Fork 528
Description
First of all, thank you for creating and maintaining this software.
I discovered today that custom nodes that print special characters cause the managed server to fail to start (at least on Windows). One example is SeedVR2 which does the following:
print(f"⚠️ SeedVR2 optimizations check: SageAttention {sage_status} | Flash Attention {flash_status} | Triton {triton_status}")
This works fine when ComfyUI is launched manually from the command line, but when it's launched by the Krita plugin, it fails with the following error:
INFO File "D:\Krita\sd\ComfyUI\custom_nodes\seedvr2_videoupscaler\src\optimization\compatibility.py", line 658, in <module>
INFO File "D:\Krita\sd\ComfyUI\app\logger.py", line 32, in write
INFO super().write(data)
INFO UnicodeEncodeError: 'cp932' codec can't encode character '\u26a0' in position 0: illegal multibyte sequence
It turns out that this is a Python problem: asyncio.create_subprocess_exec() apparently pipes the process's stdout - which is normally UTF-16 - using the system codepage, which is of course a legacy feature for programs that predate the invention of Unicode.
Fortunately, it's possible to override this by running Python in "UTF-8 mode." Going by this comment in the plugin's source code, I'm guessing Krita does this already. The plugin could do it for ComfyUI by launching it with the PYTHONUTF8 environment variable set to 1. This would also make the determine_system_encoding() function unnecessary.
(I know we're not really supposed to install extra custom nodes into the managed server, but at the same time, setting up a whole custom server just for this one upscaler seemed overkill. And who knows, maybe a prepackaged custom node - or even ComfyUI itself - will print emojis too in the future. As such, please consider addressing this.)