summaryrefslogtreecommitdiff
path: root/django/test
diff options
context:
space:
mode:
authorFlorian Apolloner <florian@apolloner.eu>2013-09-22 15:55:09 +0200
committerFlorian Apolloner <florian@apolloner.eu>2013-09-22 22:04:50 +0200
commit56201fe5a85ead96f00d8ad2eda5cfd2bc4cb4b0 (patch)
tree3a29f249ae60f1d57180e6418f20d1cd53dd480f /django/test
parentb2876c0c914be0f12b57c7e6e4f6fae671108096 (diff)
[1.6.x] Fixed "Address already in use" from liveserver.
Our WSGIServer rewrapped the socket errors from server_bind into WSGIServerExceptions, which is used later on to provide nicer error messages in runserver and used by the liveserver to see if the port is already in use. But wrapping server_bind isn't enough since it only binds to the socket, socket.listen (which is called from server_activate) could also raise "Address already in use". Instead of overriding server_activate too I chose to just catch socket errors, which seems to make more sense anyways and should be more robust against changes in wsgiref. Backport of 2ca00faa913754cd5860f6e1f23c8da2529c691a from master.
Diffstat (limited to 'django/test')
-rw-r--r--django/test/testcases.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/django/test/testcases.py b/django/test/testcases.py
index 193acaef80..85ff66a15e 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -7,6 +7,7 @@ from functools import wraps
import json
import os
import re
+import socket
import sys
import select
import socket
@@ -21,8 +22,7 @@ from django.core.handlers.wsgi import WSGIHandler
from django.core.management import call_command
from django.core.management.color import no_style
from django.core.management.commands import flush
-from django.core.servers.basehttp import (WSGIRequestHandler, WSGIServer,
- WSGIServerException)
+from django.core.servers.basehttp import WSGIRequestHandler, WSGIServer
from django.core.urlresolvers import clear_url_caches, set_urlconf
from django.db import connection, connections, DEFAULT_DB_ALIAS, transaction
from django.db.models.loading import cache
@@ -1089,10 +1089,9 @@ class LiveServerThread(threading.Thread):
try:
self.httpd = StoppableWSGIServer(
(self.host, port), QuietWSGIRequestHandler)
- except WSGIServerException as e:
+ except socket.error as e:
if (index + 1 < len(self.possible_ports) and
- hasattr(e.args[0], 'errno') and
- e.args[0].errno == errno.EADDRINUSE):
+ e.errno == errno.EADDRINUSE):
# This port is already in use, so we go on and try with
# the next one in the list.
continue