def _start_all_fixed_port(self, host_ports):
"""Starts a server for each specified address with a fixed port.
Does the work of actually trying to create a _SingleAddressWsgiServer for
each specified address.
Args:
host_ports: An iterable of host, port tuples.
Raises:
BindError: The address could not be bound.
"""
for host, port in host_ports:
assert port != 0
server = _SingleAddressWsgiServer((host, port), self._app)
try:
server.start()
except BindError as bind_error:
# TODO: I'm not sure about the behavior of quietly ignoring an
# EADDRINUSE as long as the bind succeeds on at least one interface. I
# think we should either:
# - Fail (just like we do now when bind fails on every interface).
# - Retry on next highest port.
logging.debug('Failed to bind "%s:%s": %s', host, port, bind_error)
continue
else:
self._servers.append(server)
if not self._servers:
raise BindError('Unable to bind %s:%s' % self.bind_addr)
评论列表
文章目录