Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix keepalive timeout task will not execute to close transport #1192

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions uvicorn/_handlers/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ def retrieve_exception(task: asyncio.Task) -> None:
# yet: all data that the client might have already sent since the connection has
# been established is in the `_buffer`.
data = reader._buffer # type: ignore
if data:
protocol.data_received(data)
protocol.data_received(data)

# Let the transport run in the background. When closed, this future will complete
# and we'll exit here.
Expand Down
5 changes: 5 additions & 0 deletions uvicorn/protocols/http/h11_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ def _unset_keepalive_if_required(self):

def data_received(self, data):
self._unset_keepalive_if_required()
if data == b"":
self.timeout_keep_alive_task = self.loop.call_later(
self.timeout_keep_alive, self.timeout_keep_alive_handler
)
return

self.conn.receive_data(data)
self.handle_events()
Expand Down
5 changes: 5 additions & 0 deletions uvicorn/protocols/http/httptools_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ def _unset_keepalive_if_required(self):

def data_received(self, data):
self._unset_keepalive_if_required()
if data == b"":
self.timeout_keep_alive_task = self.loop.call_later(
self.timeout_keep_alive, self.timeout_keep_alive_handler
)
return

try:
self.parser.feed_data(data)
Expand Down