From e96ed5851f9b283bae38ad96e3581c5735bbe786 Mon Sep 17 00:00:00 2001 From: Antoine Pietri Date: Mon, 11 Sep 2017 12:16:38 +0200 Subject: [PATCH] run_app: make print=None disable printing --- CONTRIBUTORS.txt | 1 + aiohttp/web.py | 3 +++ changes/2260.feature | 1 + docs/web_reference.rst | 3 ++- 4 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changes/2260.feature diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 7543c7dfd22..beef313fab7 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -29,6 +29,7 @@ Andrew Leech Andrew Lytvyn Andrew Svetlov Andrii Soldatenko +Antoine Pietri Anton Kasyanov Arthur Darcet Ben Bader diff --git a/aiohttp/web.py b/aiohttp/web.py index 6caee4ce10d..40f2c42cb04 100644 --- a/aiohttp/web.py +++ b/aiohttp/web.py @@ -422,6 +422,9 @@ def run_app(app, *, host=None, port=None, path=None, sock=None, app._set_loop(loop) loop.run_until_complete(app.startup()) + if print is None: + print = lambda *args, **kwargs: None + try: make_handler_kwargs = dict() if access_log_format is not None: diff --git a/changes/2260.feature b/changes/2260.feature new file mode 100644 index 00000000000..f78f339226a --- /dev/null +++ b/changes/2260.feature @@ -0,0 +1 @@ +run_app: Make print=None disable printing diff --git a/docs/web_reference.rst b/docs/web_reference.rst index a98929b7199..e7cb203c711 100644 --- a/docs/web_reference.rst +++ b/docs/web_reference.rst @@ -2400,7 +2400,8 @@ Utilities ``None`` for HTTP connection. :param print: a callable compatible with :func:`print`. May be used - to override STDOUT output or suppress it. + to override STDOUT output or suppress it. Passing `None` + disables output. :param int backlog: the number of unaccepted connections that the system will allow before refusing new