Skip to content

Commit

Permalink
Fix race condition with request handlers on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer authored Mar 30, 2024
1 parent 509fb26 commit 2c9e56f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions aiohttp/web_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ async def cleanup(self) -> None:
await site.stop()

if self._server: # If setup succeeded
# Yield to event loop to ensure incoming requests prior to stopping the sites
# have all started to be handled before we proceed to close idle connections.
await asyncio.sleep(0)
self._server.pre_shutdown()
await self.shutdown()

Expand Down

0 comments on commit 2c9e56f

Please sign in to comment.