Skip to content

Commit

Permalink
add comment explaining SSL Timeout thing
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin1024 committed Oct 25, 2015
1 parent 3a319b1 commit 6145475
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pytest_httpbin/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ def make_environ(self):
del environ['CONTENT_TYPE']
return environ

class MyThreadedWSGIServer(ThreadedWSGIServer):
class ThreadedWSGIServerWithSSLTimeout(ThreadedWSGIServer):
"""
This whole subclass exists just to set the ssl timeout before wrapping the
socket. That's because on pypy, if there's an SSL failure opening the
connection, it will hang forever.
"""

def __init__(self, *args, **kwargs):
self.protocol = kwargs.pop('protocol')
super(MyThreadedWSGIServer, self).__init__(*args, **kwargs)
super(ThreadedWSGIServerWithSSLTimeout, self).__init__(*args, **kwargs)

def finish_request(self, request, client_address):
"""
Expand All @@ -50,7 +55,7 @@ class Server(threading.Thread):

def __init__(self, host='127.0.0.1', port=0, application=None, protocol='http', **kwargs):
self.app = application
self._server = MyThreadedWSGIServer(
self._server = ThreadedWSGIServerWithSSLTimeout(
host,
port,
self.app,
Expand Down

0 comments on commit 6145475

Please sign in to comment.