From 094fc9a4a6dcd1e32c4a2311fd9dcbc000d4f8a1 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 21 Oct 2020 10:37:01 +0300 Subject: [PATCH 1/2] Reduce sleep time on Windows --- aiohttp/web.py | 11 ++++++++++- vendor/http-parser | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/aiohttp/web.py b/aiohttp/web.py index a5de6fcee54..21522620623 100644 --- a/aiohttp/web.py +++ b/aiohttp/web.py @@ -372,8 +372,17 @@ async def _run_app(app: Union[Application, Awaitable[Application]], *, names = sorted(str(s.name) for s in runner.sites) print("======== Running on {} ========\n" "(Press CTRL+C to quit)".format(', '.join(names))) + + # sleep forever by 1 hour intervals, + # on Windows before Python 3.8 wake up every 1 second to handle + # Ctrl+C smoothly + if sys.platform == "win32" and sys.version_info < 3.8: + delay = 1 + else: + delay = 3600 + while True: - await asyncio.sleep(3600) # sleep forever by 1 hour intervals + await asyncio.sleep(delay) finally: await runner.cleanup() diff --git a/vendor/http-parser b/vendor/http-parser index 77310eeb839..2343fd6b521 160000 --- a/vendor/http-parser +++ b/vendor/http-parser @@ -1 +1 @@ -Subproject commit 77310eeb839c4251c07184a5db8885a572a08352 +Subproject commit 2343fd6b5214b2ded2cdcf76de2bf60903bb90cd From 70531d51d78c9776e25b72525e288777a7b93344 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 21 Oct 2020 10:42:16 +0300 Subject: [PATCH 2/2] Add changelog --- CHANGES/5098.bugfix | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 CHANGES/5098.bugfix diff --git a/CHANGES/5098.bugfix b/CHANGES/5098.bugfix new file mode 100644 index 00000000000..0bd27fe7fb8 --- /dev/null +++ b/CHANGES/5098.bugfix @@ -0,0 +1,2 @@ +Make `web.run_app()` more responsive to Ctrl+C on Windows for Python < 3.8. It slightly +increases CPU load as a side effect.