Convert server lambda to partial

Partials are faster then lambdas for repeated calls.
This commit is contained in:
John Piasetzki 2016-11-25 14:53:18 -05:00
parent fc19f2ea34
commit 13808bf282

View File

@ -235,14 +235,23 @@ def serve(host, port, request_handler, before_start=None, after_start=None,
connections = {}
signal = Signal()
server_coroutine = loop.create_server(lambda: HttpProtocol(
server = partial(
HttpProtocol,
loop=loop,
connections=connections,
signal=signal,
request_handler=request_handler,
request_timeout=request_timeout,
request_max_size=request_max_size,
), host, port, reuse_port=reuse_port, sock=sock)
)
server_coroutine = loop.create_server(
server,
host,
port,
reuse_port=reuse_port,
sock=sock
)
# Instead of pulling time at the end of every request,
# pull it once per minute