Skip to content

Commit

Permalink
Merge pull request #332 from Pylons/fix-default-logging
Browse files Browse the repository at this point in the history
fix a crash in the MultiSocketServer startup and re-enable startup messages
  • Loading branch information
digitalresistor authored Nov 29, 2020
2 parents 665240e + 994b556 commit 19793c0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
unreleased
----------

- Fix a crash on startup when listening to multiple interfaces.
See https://github.com/Pylons/waitress/pull/332

2.0.0b0 (2020-11-26)
--------------------

Expand Down
8 changes: 8 additions & 0 deletions src/waitress/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@


import getopt
import logging
import os
import os.path
import re
import sys

from waitress import serve
from waitress.adjustments import Adjustments
from waitress.utilities import logger

HELP = """\
Usage:
Expand Down Expand Up @@ -260,6 +262,12 @@ def run(argv=sys.argv, _serve=serve):
show_help(sys.stderr, name, "Specify one application only")
return 1

# set a default level for the logger only if it hasn't been set explicitly
# note that this level does not override any parent logger levels,
# handlers, etc but without it no log messages are emitted by default
if logger.level == logging.NOTSET:
logger.setLevel(logging.INFO)

try:
module, obj_name = match(args[0])
except ValueError as exc:
Expand Down
7 changes: 5 additions & 2 deletions src/waitress/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ def create_server(
# In this case we have no need to use a MultiSocketServer
return last_serv

log_info = last_serv.log_info
# Return a class that has a utility function to print out the sockets it's
# listening on, and has a .run() function. All of the TcpWSGIServers
# registered themselves in the map above.
return MultiSocketServer(map, adj, effective_listen, dispatcher)
return MultiSocketServer(map, adj, effective_listen, dispatcher, log_info)


# This class is only ever used if we have multiple listen sockets. It allows
Expand All @@ -143,11 +144,13 @@ def __init__(
adj=None,
effective_listen=None,
dispatcher=None,
log_info=None,
):
self.adj = adj
self.map = map
self.effective_listen = effective_listen
self.task_dispatcher = dispatcher
self.log_info = log_info

def print_listen(self, format_str): # pragma: nocover
for l in self.effective_listen:
Expand Down Expand Up @@ -344,7 +347,7 @@ def maintenance(self, now):
if (not channel.requests) and channel.last_activity < cutoff:
channel.will_close = True

def print_listen(self, format_str): # pragma: nocover
def print_listen(self, format_str): # pragma: no cover
self.log_info(format_str.format(self.effective_host, self.effective_port))

def close(self):
Expand Down

0 comments on commit 19793c0

Please sign in to comment.