Use explicit import for httptools

Explicit importing the parser and the exception to save a name lookup.
This commit is contained in:
John Piasetzki 2016-11-25 14:33:17 -05:00
parent fc19f2ea34
commit 0ca5c4eeff

View File

@ -4,7 +4,8 @@ from inspect import isawaitable
from multidict import CIMultiDict from multidict import CIMultiDict
from signal import SIGINT, SIGTERM from signal import SIGINT, SIGTERM
from time import time from time import time
import httptools from httptools import HttpRequestParser
from httptools.parser.errors import HttpParserError
try: try:
import uvloop as async_loop import uvloop as async_loop
@ -94,12 +95,12 @@ class HttpProtocol(asyncio.Protocol):
if self.parser is None: if self.parser is None:
assert self.request is None assert self.request is None
self.headers = [] self.headers = []
self.parser = httptools.HttpRequestParser(self) self.parser = HttpRequestParser(self)
# Parse request chunk or close connection # Parse request chunk or close connection
try: try:
self.parser.feed_data(data) self.parser.feed_data(data)
except httptools.parser.errors.HttpParserError as e: except HttpParserError as e:
self.bail_out( self.bail_out(
"Invalid request data, connection closed ({})".format(e)) "Invalid request data, connection closed ({})".format(e))