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

[protocols/httptools_impl.py] Replace list with deque for pipeline #1213

Merged
merged 1 commit into from
Oct 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions uvicorn/protocols/http/httptools_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import re
import urllib
from collections import deque
from typing import Callable

import httptools
Expand Down Expand Up @@ -74,7 +75,7 @@ def __init__(
self.server = None
self.client = None
self.scheme = None
self.pipeline = []
self.pipeline = deque()

# Per-request state
self.url = None
Expand Down Expand Up @@ -259,7 +260,7 @@ def on_headers_complete(self):
else:
# Pipelined HTTP requests need to be queued up.
self.flow.pause_reading()
self.pipeline.insert(0, (self.cycle, app))
self.pipeline.appendleft((self.cycle, app))

def on_body(self, body: bytes):
if self.parser.should_upgrade() or self.cycle.response_complete:
Expand Down