Skip to content

Commit c364ad0

Browse files
committed
run_app: make print=None disable printing
1 parent c7e8356 commit c364ad0

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

CONTRIBUTORS.txt

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Andrew Leech
2929
Andrew Lytvyn
3030
Andrew Svetlov
3131
Andrii Soldatenko
32+
Antoine Pietri
3233
Anton Kasyanov
3334
Arthur Darcet
3435
Ben Bader

aiohttp/web.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,9 @@ def run_app(app, *, host=None, port=None, path=None, sock=None,
447447
pass
448448

449449
try:
450-
print("======== Running on {} ========\n"
451-
"(Press CTRL+C to quit)".format(', '.join(uris)))
450+
if print:
451+
print("======== Running on {} ========\n"
452+
"(Press CTRL+C to quit)".format(', '.join(uris)))
452453
loop.run_forever()
453454
except (GracefulExit, KeyboardInterrupt): # pragma: no cover
454455
pass

changes/2260.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
run_app: Make print=None disable printing

docs/web_reference.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -2400,7 +2400,8 @@ Utilities
24002400
``None`` for HTTP connection.
24012401

24022402
:param print: a callable compatible with :func:`print`. May be used
2403-
to override STDOUT output or suppress it.
2403+
to override STDOUT output or suppress it. Passing `None`
2404+
disables output.
24042405

24052406
:param int backlog: the number of unaccepted connections that the
24062407
system will allow before refusing new

tests/test_run_app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def test_run_app_mixed_bindings(mocker, run_app_kwargs, expected_server_calls,
214214
loop = mocker.MagicMock()
215215
mocker.patch('asyncio.gather')
216216

217-
web.run_app(app, loop=loop, print=lambda *args: None, **run_app_kwargs)
217+
web.run_app(app, loop=loop, print=None, **run_app_kwargs)
218218

219219
assert loop.create_unix_server.mock_calls == expected_unix_server_calls
220220
assert loop.create_server.mock_calls == expected_server_calls

0 commit comments

Comments
 (0)