cpython/Lib/asyncio
Guido van Rossum 2655369559
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>
2023-10-28 18:04:29 +00:00
..
__init__.py
__main__.py
base_events.py gh-79033: Try to fix asyncio.Server.wait_closed() again (GH-111336) 2023-10-28 18:04:29 +00:00
base_futures.py
base_subprocess.py
base_tasks.py
constants.py
coroutines.py
events.py
exceptions.py
format_helpers.py
futures.py
locks.py
log.py
mixins.py
proactor_events.py
protocols.py
queues.py
runners.py
selector_events.py
sslproto.py
staggered.py
streams.py Remove loop from docstring for asyncio.streams.open_connection (#108528) 2023-09-26 20:34:15 -07:00
subprocess.py gh-109709: Fix asyncio test_stdin_broken_pipe() (#109710) 2023-09-22 15:29:42 +02:00
taskgroups.py gh-111085: Fix invalid state handling in TaskGroup and Timeout (#111111) 2023-10-21 22:18:34 +03:00
tasks.py gh-110961: Fixed asyncio.wait docstring to remove deprecated coroutine reference (#111017) 2023-10-18 04:40:26 +00:00
threads.py
timeouts.py gh-111085: Fix invalid state handling in TaskGroup and Timeout (#111111) 2023-10-21 22:18:34 +03:00
transports.py
trsock.py
unix_events.py gh-110205: Fix asyncio ThreadedChildWatcher._join_threads() (#110884) 2023-10-27 15:44:12 -07:00
windows_events.py gh-110771: Decompose run_forever() into parts (#110773) 2023-10-13 14:12:32 +00:00
windows_utils.py