Print out socket errors in HTTPS server thread

This commit is contained in:
Antoine Pitrou 2010-10-13 11:51:05 +00:00
parent 05d936d2ce
commit 84fa4314ba
1 changed files with 9 additions and 2 deletions

View File

@ -2,6 +2,7 @@ import os
import sys
import ssl
import pprint
import socket
import threading
import urllib.parse
# Rename HTTPServer to _HTTPServer so as to avoid confusion with HTTPSServer.
@ -31,8 +32,14 @@ class HTTPSServer(_HTTPServer):
def get_request(self):
# override this to wrap socket with SSL
sock, addr = self.socket.accept()
sslconn = self.context.wrap_socket(sock, server_side=True)
try:
sock, addr = self.socket.accept()
sslconn = self.context.wrap_socket(sock, server_side=True)
except socket.error as e:
# socket errors are silenced by the caller, print them here
if support.verbose:
sys.stderr.write("Got an error:\n%s\n" % e)
raise
return sslconn, addr
class RootedHTTPRequestHandler(SimpleHTTPRequestHandler):