mirror of https://github.com/vitalif/phantomjs
Set SO_REUSEADDR on the test server's listening port.
This means you don't have to wait 30 seconds in between invocations of run-tests.py. Also, if the test server fails to bind its port, print the actual OS-level error message rather than guessing what the problem is. issue #124392.0
parent
3d4f89b41e
commit
4d4aa42c94
|
@ -140,6 +140,12 @@ class FileHandler(SimpleHTTPServer.SimpleHTTPRequestHandler, object):
|
|||
self._cached_translated_path = path
|
||||
return path
|
||||
|
||||
# This is how you are officially supposed to set SO_REUSEADDR per
|
||||
# https://docs.python.org/2/library/socketserver.html#SocketServer.BaseServer.allow_reuse_address
|
||||
|
||||
class TCPServer(SocketServer.TCPServer):
|
||||
allow_reuse_address = True
|
||||
|
||||
def run_httpd():
|
||||
global http_running
|
||||
handler = FileHandler
|
||||
|
@ -151,12 +157,12 @@ def run_httpd():
|
|||
'.json': 'application/json'
|
||||
})
|
||||
try:
|
||||
httpd = SocketServer.TCPServer(('', HTTP_PORT), handler)
|
||||
httpd = TCPServer(('', HTTP_PORT), handler)
|
||||
while http_running:
|
||||
httpd.handle_request()
|
||||
except socket.error:
|
||||
except socket.error as e:
|
||||
print 'Fatal error: unable to launch a test server at port', HTTP_PORT
|
||||
print 'Check that the port is not already used!'
|
||||
print str(e)
|
||||
http_running = False
|
||||
sys.exit(1)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue