diff --git a/channels/exceptions.py b/channels/exceptions.py index 502358e..2c8a359 100644 --- a/channels/exceptions.py +++ b/channels/exceptions.py @@ -1,4 +1,5 @@ from __future__ import unicode_literals + import six diff --git a/channels/handler.py b/channels/handler.py index f6bd821..cd44f45 100644 --- a/channels/handler.py +++ b/channels/handler.py @@ -12,7 +12,6 @@ from django import http from django.conf import settings from django.core import signals from django.core.handlers import base - from django.http import FileResponse, HttpResponse, HttpResponseServerError from django.utils import six from django.utils.functional import cached_property diff --git a/channels/management/commands/runserver.py b/channels/management/commands/runserver.py index 7caccbe..037d7fe 100644 --- a/channels/management/commands/runserver.py +++ b/channels/management/commands/runserver.py @@ -25,12 +25,16 @@ class Command(RunserverCommand): parser.add_argument('--noasgi', action='store_false', dest='use_asgi', default=True, help='Run the old WSGI-based runserver rather than the ASGI-based one') parser.add_argument('--http_timeout', action='store', dest='http_timeout', type=int, default=60, - help='Specify the daphane http_timeout interval in seconds (default: 60)') + help='Specify the daphne http_timeout interval in seconds (default: 60)') + parser.add_argument('--websocket_handshake_timeout', action='store', dest='websocket_handshake_timeout', + type=int, default=5, + help='Specify the daphne websocket_handshake_timeout interval in seconds (default: 5)') def handle(self, *args, **options): self.verbosity = options.get("verbosity", 1) self.logger = setup_logger('django.channels', self.verbosity) self.http_timeout = options.get("http_timeout", 60) + self.websocket_handshake_timeout = options.get("websocket_handshake_timeout", 5) super(Command, self).handle(*args, **options) def inner_run(self, *args, **options): @@ -88,6 +92,7 @@ class Command(RunserverCommand): http_timeout=self.http_timeout, ws_protocols=getattr(settings, 'CHANNELS_WS_PROTOCOLS', None), root_path=getattr(settings, 'FORCE_SCRIPT_NAME', '') or '', + websocket_handshake_timeout=self.websocket_handshake_timeout, ).run() self.logger.debug("Daphne exited") except KeyboardInterrupt: diff --git a/channels/package_checks.py b/channels/package_checks.py index 6e4bbf8..bf72ec0 100644 --- a/channels/package_checks.py +++ b/channels/package_checks.py @@ -1,7 +1,6 @@ import importlib from distutils.version import StrictVersion - required_versions = { "asgi_rabbitmq": "0.4.0", "asgi_redis": "1.2.0", diff --git a/channels/test/websocket.py b/channels/test/websocket.py index 66fe216..4b762ce 100644 --- a/channels/test/websocket.py +++ b/channels/test/websocket.py @@ -4,7 +4,6 @@ import json import six from django.apps import apps from django.conf import settings - from django.http.cookie import SimpleCookie from ..sessions import session_for_reply_channel diff --git a/tests/test_management.py b/tests/test_management.py index 89b0bc1..ab2b852 100644 --- a/tests/test_management.py +++ b/tests/test_management.py @@ -138,6 +138,7 @@ class RunServerTests(TestCase): channel_layer=mock.ANY, ws_protocols=None, root_path='', + websocket_handshake_timeout=5, ) @mock.patch('channels.management.commands.runserver.sys.stdout', new_callable=StringIO) @@ -158,6 +159,7 @@ class RunServerTests(TestCase): channel_layer=mock.ANY, ws_protocols=None, root_path='', + websocket_handshake_timeout=5, ) call_command('runserver', '--noreload', 'localhost:8001') @@ -169,6 +171,7 @@ class RunServerTests(TestCase): channel_layer=mock.ANY, ws_protocols=None, root_path='', + websocket_handshake_timeout=5, ) self.assertFalse( @@ -192,6 +195,7 @@ class RunServerTests(TestCase): channel_layer=mock.ANY, ws_protocols=None, root_path='', + websocket_handshake_timeout=5, ) self.assertFalse( mocked_worker.called,