当前位置: 首页>>代码示例>>Python>>正文


Python BaseServer.handle_error方法代码示例

本文整理汇总了Python中socketserver.BaseServer.handle_error方法的典型用法代码示例。如果您正苦于以下问题:Python BaseServer.handle_error方法的具体用法?Python BaseServer.handle_error怎么用?Python BaseServer.handle_error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在socketserver.BaseServer的用法示例。


在下文中一共展示了BaseServer.handle_error方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle_error

# 需要导入模块: from socketserver import BaseServer [as 别名]
# 或者: from socketserver.BaseServer import handle_error [as 别名]
  def handle_error( self, request, client_address ):
    # Override default behaviour of error handler in ThreadingMixIn
    # the default handler prints and error message to stdout and stderr.
    # Instead, this re-raises the exception so that it can be caught and 
    # dealt with sensibly!

    print("handle_error!");
    exc_type, exc_value, exc_traceback = sys.exc_info();
    #if exc_type == SSL.Error and exc_value[0][0][2]=='http request':
    print(exc_type);
    print(exc_value);
    print(exc_traceback);
    print("OpenSLL error detected!");

      # We would like to send back a BadRequest to the web-client indicating
      # that they made an http request to this https server (like apache does).
      # But this response message must be sent via http (not https), but this 
      # server's __init__ function sets up an SSL server, so this seems
      # difficult to to.
      # It might be possible to make a mixed server than can serve both types
      # of requests, but this is left for later.

    # Fall back to original error handler.
    # Print: exc_type, exc_value, exc_traceback.
    BaseServer.handle_error( self, request, client_address );
开发者ID:WimbledonLabs,项目名称:sous-vide-cooker,代码行数:27,代码来源:SnakeCharmer.py


注:本文中的socketserver.BaseServer.handle_error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。