-
Notifications
You must be signed in to change notification settings - Fork 16
开始打包 #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
开始打包 #156
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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() | ||
|
|
||
| if exit_code == EXIT_CODE_RESTART: | ||
| logger.info("检测到重启信号,正在重启应用程序...") | ||
|
|
@@ -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
|
||
| os._exit(1) | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
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.stdoutmight 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.