From 8f3d8f2d764dbf01483b7ea0f937c6cba592da06 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Thu, 15 Jun 2017 01:34:42 +0300 Subject: [PATCH] Fix #1947: don't raise DeprecationWarning inside on_startup() handler for run_app() --- CHANGES.rst | 2 +- aiohttp/web.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index d1640a92bb3..e7fc064c01e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -18,7 +18,7 @@ Changes - Use CIMultiDict for ClientRequest.skip_auto_headers #1970 -- Fix wrong startup sequence: test server doesn't raise +- Fix wrong startup sequence: test server and `run_app()` are not raise `DeprecationWarning` now #1947 - diff --git a/aiohttp/web.py b/aiohttp/web.py index 47e0f536fe6..e6d319fd93f 100644 --- a/aiohttp/web.py +++ b/aiohttp/web.py @@ -336,14 +336,15 @@ def run_app(app, *, host=None, port=None, path=None, sock=None, if loop is None: loop = asyncio.get_event_loop() + app._set_loop(loop) + loop.run_until_complete(app.startup()) + make_handler_kwargs = dict() if access_log_format is not None: make_handler_kwargs['access_log_format'] = access_log_format handler = app.make_handler(loop=loop, access_log=access_log, **make_handler_kwargs) - loop.run_until_complete(app.startup()) - scheme = 'https' if ssl_context else 'http' base_url = URL('{}://localhost'.format(scheme)).with_port(port)