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]")