Skip to content

Commit c562ffe

Browse files
hynekasvetlov
authored andcommitted
Allow run_app(access_log=None) (#3504)
* Mark access_log as optional * Make access_log=None work in debug mode
1 parent d487af9 commit c562ffe

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CHANGES/3504.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix type stubs for ``aiohttp.web.run_app(access_log=True)`` and fix edge case of ``access_log=True`` and the event loop being in debug mode.

aiohttp/web.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ async def _run_app(app: Union[Application, Awaitable[Application]], *,
269269
backlog: int=128,
270270
access_log_class: Type[AbstractAccessLogger]=AccessLogger,
271271
access_log_format: str=AccessLogger.LOG_FORMAT,
272-
access_log: logging.Logger=access_logger,
272+
access_log: Optional[logging.Logger]=access_logger,
273273
handle_signals: bool=True,
274274
reuse_address: Optional[bool]=None,
275275
reuse_port: Optional[bool]=None) -> None:
@@ -383,15 +383,15 @@ def run_app(app: Union[Application, Awaitable[Application]], *,
383383
backlog: int=128,
384384
access_log_class: Type[AbstractAccessLogger]=AccessLogger,
385385
access_log_format: str=AccessLogger.LOG_FORMAT,
386-
access_log: logging.Logger=access_logger,
386+
access_log: Optional[logging.Logger]=access_logger,
387387
handle_signals: bool=True,
388388
reuse_address: Optional[bool]=None,
389389
reuse_port: Optional[bool]=None) -> None:
390390
"""Run an app locally"""
391391
loop = asyncio.get_event_loop()
392392

393393
# Configure if and only if in debugging mode and using the default logger
394-
if loop.get_debug() and access_log.name == 'aiohttp.access':
394+
if loop.get_debug() and access_log and access_log.name == 'aiohttp.access':
395395
if access_log.level == logging.NOTSET:
396396
access_log.setLevel(logging.DEBUG)
397397
if not access_log.hasHandlers():

0 commit comments

Comments
 (0)