Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Lib/asyncio/base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,15 @@ def _detach(self, transport):

def _wakeup(self):
waiters = self._waiters
if waiters is None:
# gh109564: the wakeup method has two possible call-sites, through an
# explicit call to the server's close method, or indirectly after the last
# client disconnects and the corresponding transport detaches from the
# server. These two can be in a race-condition if the server closes between
# `BaseSelectorEventLoop._accept_connection` and
# `BaseSelectorEventLoop._accept_connection2`; in this scenario we must
# check the wakeup call hasn't already set the server waiters to None.
return
self._waiters = None
for waiter in waiters:
if not waiter.done():
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix race condition in :meth:`asyncio.Server.close`. Patch by Jamie Phan.
Loading