summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2023-10-28 18:04:29 (GMT)
committerGitHub <noreply@github.com>2023-10-28 18:04:29 (GMT)
commit26553695592ad399f735d4dbaf32fd871d0bb1e1 (patch)
tree7f777a94e61f9cdc97a961f235019034f0411b3c /Doc/library
parent9d4a1a480b65196c3aabbcd2d165d1fb86d0c8e5 (diff)
downloadcpython-26553695592ad399f735d4dbaf32fd871d0bb1e1.zip
cpython-26553695592ad399f735d4dbaf32fd871d0bb1e1.tar.gz
cpython-26553695592ad399f735d4dbaf32fd871d0bb1e1.tar.bz2
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 --------- Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/asyncio-eventloop.rst8
1 files changed, 5 insertions, 3 deletions
diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst
index 75c459c..5627f0d 100644
--- a/Doc/library/asyncio-eventloop.rst
+++ b/Doc/library/asyncio-eventloop.rst
@@ -1619,8 +1619,9 @@ Do not instantiate the :class:`Server` class directly.
The sockets that represent existing incoming client connections
are left open.
- The server is closed asynchronously, use the :meth:`wait_closed`
- coroutine to wait until the server is closed.
+ The server is closed asynchronously; use the :meth:`wait_closed`
+ coroutine to wait until the server is closed (and no more
+ connections are active).
.. method:: get_loop()
@@ -1678,7 +1679,8 @@ Do not instantiate the :class:`Server` class directly.
.. coroutinemethod:: wait_closed()
- Wait until the :meth:`close` method completes.
+ Wait until the :meth:`close` method completes and all active
+ connections have finished.
.. attribute:: sockets