From 2e1139d1018e3a7d4ba5569bdd71f36ea0ada4f1 Mon Sep 17 00:00:00 2001 From: CakeCN Date: Thu, 8 Jan 2026 00:31:48 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B2=E6=AD=A2=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E5=AE=95=E6=9C=BA=20=EF=BC=9A=20Socket=20operation=20on=20non-?= =?UTF-8?q?socket=20=E9=94=99=E8=AF=AF=E4=B8=8D=E4=BC=9A=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code-server-like/app/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code-server-like/app/__init__.py b/code-server-like/app/__init__.py index 91d797d..f7a1280 100644 --- a/code-server-like/app/__init__.py +++ b/code-server-like/app/__init__.py @@ -48,8 +48,9 @@ try: def custom_excepthook(exc_type, exc_value, exc_traceback): """全局异常钩子,捕获所有未处理的异常""" - if exc_type.__name__ in ['OSError', 'IOError'] and 'Bad file descriptor' in str(exc_value): - # 处理 Bad file descriptor 错误,不导致服务器宕机 + error_str = str(exc_value) + if exc_type.__name__ in ['OSError', 'IOError'] and any(msg in error_str for msg in ['Bad file descriptor', 'Socket operation on non-socket', 'Operation on closed file']): + # 处理各种socket错误,不导致服务器宕机 if not is_duplicate_error(exc_value): print(f"[Global Error Handler] {exc_type.__name__}: {exc_value}") print("[Traceback]")