diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-10-28 18:42:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-28 18:42:53 (GMT) |
commit | 2e5d4e24ebcd671915427b6fd35a5b0eea412c4a (patch) | |
tree | 9d35edf6dbb5a2e517eed6da0a4820b870f3f947 /Misc/NEWS.d | |
parent | cf29a2f25e359790c0c0f6a4ab0ab49ca5ffab5d (diff) | |
download | cpython-2e5d4e24ebcd671915427b6fd35a5b0eea412c4a.zip cpython-2e5d4e24ebcd671915427b6fd35a5b0eea412c4a.tar.gz cpython-2e5d4e24ebcd671915427b6fd35a5b0eea412c4a.tar.bz2 |
[3.12] gh-79033: Try to fix asyncio.Server.wait_closed() again (GH-111336) (#111424)
gh-79033: Try to fix asyncio.Server.wait_closed() again (GH-111336)
* Try to fix asyncio.Server.wait_closed() again
I identified the condition that `wait_closed()` is intended
to wait for: the server is closed *and* there are no more
active connections.
When this condition first becomes true, `_wakeup()` is called
(either from `close()` or from `_detach()`) and it sets `_waiters`
to `None`. So we just check for `self._waiters is None`; if it's
not `None`, we know we have to wait, and do so.
A problem was that the new test introduced in 3.12 explicitly
tested that `wait_closed()` returns immediately when the server
is *not* closed but there are currently no active connections.
This was a mistake (probably a misunderstanding of the intended
semantics). I've fixed the test, and added a separate test that
checks exactly for this scenario.
I also fixed an oddity where in `_wakeup()` the result of the
waiter was set to the waiter itself. This result is not used
anywhere and I changed this to `None`, to avoid a GC cycle.
* Update Lib/asyncio/base_events.py
---------
(cherry picked from commit 26553695592ad399f735d4dbaf32fd871d0bb1e1)
Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Diffstat (limited to 'Misc/NEWS.d')
-rw-r--r-- | Misc/NEWS.d/next/Library/2023-10-25-11-54-00.gh-issue-79033.5ePgFl.rst | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2023-10-25-11-54-00.gh-issue-79033.5ePgFl.rst b/Misc/NEWS.d/next/Library/2023-10-25-11-54-00.gh-issue-79033.5ePgFl.rst new file mode 100644 index 0000000..f131bf5 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-10-25-11-54-00.gh-issue-79033.5ePgFl.rst @@ -0,0 +1,6 @@ +Another attempt at fixing :func:`asyncio.Server.wait_closed()`. It now +blocks until both conditions are true: the server is closed, *and* there +are no more active connections. (This means that in some cases where in +3.12.0 this function would *incorrectly* have returned immediately, +it will now block; in particular, when there are no active connections +but the server hasn't been closed yet.) |