[protocols/httptools_impl.py] Replace list with deque for `pipeline`
@@ -3,6 +3,7 @@ import http
import logging
import re
import urllib
+from collections import deque
from typing import Callable
import httptools
@@ -74,7 +75,7 @@ class HttpToolsProtocol(asyncio.Protocol):
self.server = None
self.client = None
self.scheme = None
- self.pipeline = []
+ self.pipeline = deque()
# Per-request state
self.url = None
@@ -259,7 +260,7 @@ class HttpToolsProtocol(asyncio.Protocol):
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:
