add configurable backlog #263

This commit is contained in:
Raphael Deem 2017-01-03 18:35:11 -08:00
parent 16959caa34
commit e7922c1b54
2 changed files with 7 additions and 4 deletions

View File

@ -20,7 +20,7 @@ from .exceptions import ServerError
class Sanic:
def __init__(self, name=None, router=None,
error_handler=None, logger=None):
error_handler=None, logger=None, backlog=100):
if logger is None:
logging.basicConfig(
level=logging.INFO,
@ -29,6 +29,7 @@ class Sanic:
if name is None:
frame_records = stack()[1]
name = getmodulename(frame_records[1])
self.backlog = backlog
self.name = name
self.router = router or Router()
self.error_handler = error_handler or Handler(self)
@ -278,7 +279,8 @@ class Sanic:
'error_handler': self.error_handler,
'request_timeout': self.config.REQUEST_TIMEOUT,
'request_max_size': self.config.REQUEST_MAX_SIZE,
'loop': loop
'loop': loop,
'backlog': self.backlog
}
# -------------------------------------------- #

View File

@ -226,7 +226,7 @@ def trigger_events(events, loop):
def serve(host, port, request_handler, error_handler, before_start=None,
after_start=None, before_stop=None, after_stop=None, debug=False,
request_timeout=60, sock=None, request_max_size=None,
reuse_port=False, loop=None, protocol=HttpProtocol):
reuse_port=False, loop=None, protocol=HttpProtocol, backlog=100):
"""
Starts asynchronous HTTP Server on an individual process.
:param host: Address to host on
@ -276,7 +276,8 @@ def serve(host, port, request_handler, error_handler, before_start=None,
host,
port,
reuse_port=reuse_port,
sock=sock
sock=sock,
backlog=backlog
)
# Instead of pulling time at the end of every request,