从run 中移除了全局try-except块,增强了eventlet内部错误处理
This commit is contained in:
@@ -10,23 +10,11 @@ logging.getLogger('werkzeug').setLevel(logging.ERROR)
|
||||
app = create_app()
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
socketio.run(
|
||||
app,
|
||||
host="0.0.0.0",
|
||||
port=5200,
|
||||
debug=False, # 开发期打开
|
||||
allow_unsafe_werkzeug=True, # 避免 dev server 的安全限制提示
|
||||
log_output=False # 禁用详细输出
|
||||
)
|
||||
except KeyboardInterrupt:
|
||||
print("Server stopped by user")
|
||||
except Exception as e:
|
||||
# 捕获所有异常,包括 eventlet 内部的 IOClosed 错误
|
||||
if "IOClosed" in str(type(e).__name__) or "Operation on closed file" in str(e):
|
||||
# 优雅处理 eventlet 关闭文件的错误
|
||||
print("Eventlet IOClosed error handled gracefully")
|
||||
else:
|
||||
# 其他异常仍然打印
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
socketio.run(
|
||||
app,
|
||||
host="0.0.0.0",
|
||||
port=5200,
|
||||
debug=False, # 开发期打开
|
||||
allow_unsafe_werkzeug=True, # 避免 dev server 的安全限制提示
|
||||
log_output=False # 禁用详细输出
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user