From 8c031239adc994b1c75f5a99ae319a3838a6a721 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Wed, 30 May 2018 09:52:47 -0700 Subject: [PATCH] Remove HTTP timeout by default, and mid-response error for it --- daphne/cli.py | 2 +- daphne/http_protocol.py | 8 ++++++-- daphne/server.py | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/daphne/cli.py b/daphne/cli.py index 7361914..d9d9fb4 100755 --- a/daphne/cli.py +++ b/daphne/cli.py @@ -86,7 +86,7 @@ class CommandLineInterface(object): "--http-timeout", type=int, help="How long to wait for worker before timing out HTTP connections", - default=120, + default=None, ) self.parser.add_argument( "--access-log", diff --git a/daphne/http_protocol.py b/daphne/http_protocol.py index 060aab5..2c946e1 100755 --- a/daphne/http_protocol.py +++ b/daphne/http_protocol.py @@ -256,8 +256,12 @@ class WebRequest(http.Request): Called periodically to see if we should timeout something """ # Web timeout checking - if self.duration() > self.server.http_timeout: - self.basic_error(503, b"Service Unavailable", "Application failed to respond within time limit.") + if self.server.http_timeout and self.duration() > self.server.http_timeout: + if self._response_started: + logger.warning("Application timed out while sending response") + self.finish() + else: + self.basic_error(503, b"Service Unavailable", "Application failed to respond within time limit.") ### Utility functions diff --git a/daphne/server.py b/daphne/server.py index c9ab4a3..6a65ebb 100755 --- a/daphne/server.py +++ b/daphne/server.py @@ -42,7 +42,7 @@ class Server(object): endpoints=None, signal_handlers=True, action_logger=None, - http_timeout=120, + http_timeout=None, websocket_timeout=86400, websocket_connect_timeout=20, ping_interval=20,