chore: update Python RPC environment settings for UTF-8 encoding and adjust logging configuration (#2219)

This commit is contained in:
Moyase
2026-05-08 13:06:31 +03:00
committed by GitHub
parent 304eeb70f4
commit f8d5f8e369
2 changed files with 18 additions and 0 deletions
+8
View File
@@ -13,6 +13,14 @@ import libtorrent as lt
from torrent_downloader import TorrentDownloader
for _stream in (sys.stdin, sys.stdout, sys.stderr):
reconfigure = getattr(_stream, "reconfigure", None)
if callable(reconfigure):
try:
reconfigure(encoding="utf-8", errors="strict")
except (ValueError, OSError):
pass
logging.basicConfig(
level=logging.INFO,
format="[%(asctime)s] %(levelname)s %(name)s: %(message)s",
+10
View File
@@ -334,6 +334,11 @@ export class PythonRPC {
const childProcess = cp.spawn(binaryPath, commonArgs, {
windowsHide: true,
stdio: ["pipe", "pipe", "pipe"],
env: {
...process.env,
PYTHONIOENCODING: "utf-8",
PYTHONUTF8: "1",
},
});
this.logStderr(childProcess.stderr);
@@ -355,6 +360,11 @@ export class PythonRPC {
[scriptPath, ...commonArgs],
{
stdio: ["pipe", "pipe", "pipe"],
env: {
...process.env,
PYTHONIOENCODING: "utf-8",
PYTHONUTF8: "1",
},
}
);