本文整理汇总了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 );