Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,10 @@ def new_notify(receiver, event):
logger.debug("垃圾回收已完成")

logger.info("程序退出流程已完成,正在结束进程")
sys.stdout.flush()
sys.stderr.flush()
if sys.stdout:
sys.stdout.flush()
if sys.stderr:
sys.stderr.flush()
Comment on lines +205 to +208
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition if sys.stdout: may not be sufficient for packaged applications. In some environments, sys.stdout might be a non-None object that doesn't support the flush operation, or could be a redirected stream. Consider using a try-except block around the flush operations instead, which would be more robust and handle edge cases where the stream exists but flush() fails.

Copilot uses AI. Check for mistakes.

if exit_code == EXIT_CODE_RESTART:
logger.info("检测到重启信号,正在重启应用程序...")
Expand Down Expand Up @@ -255,8 +257,10 @@ def new_notify(receiver, event):
shared_memory.detach()
if "local_server" in locals() and local_server:
local_server.close()
sys.stdout.flush()
sys.stderr.flush()
if sys.stdout:
sys.stdout.flush()
if sys.stderr:
sys.stderr.flush()
Comment on lines +260 to +263
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition if sys.stdout: may not be sufficient for packaged applications. In some environments, sys.stdout might be a non-None object that doesn't support the flush operation, or could be a redirected stream. Consider using a try-except block around the flush operations instead, which would be more robust and handle edge cases where the stream exists but flush() fails.

Copilot uses AI. Check for mistakes.
os._exit(1)


Expand Down
Loading