Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Fix asyncio.Server.wait_closed()
It was a no-op when used as recommended (after close()).

I had to debug one test (test__sock_sendfile_native_failure) --
the cleanup sequence for the test fixture was botched.

Hopefully that's not a portend of problems in user code --
this has never worked so people may well be doing this wrong. :-(
  • Loading branch information
gvanrossum committed Oct 24, 2022
commit d2eca9506ef2627108637be14e60295cc2088bc0
2 changes: 1 addition & 1 deletion Lib/asyncio/base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ async def serve_forever(self):
self._serving_forever_fut = None

async def wait_closed(self):
if self._sockets is None or self._waiters is None:
if self._waiters is None or self._active_count == 0:
return
waiter = self._loop.create_future()
self._waiters.append(waiter)
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_asyncio/test_base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2052,11 +2052,11 @@ def prepare(self):

def cleanup():
server.close()
self.run_loop(server.wait_closed())
sock.close()
if proto.transport is not None:
proto.transport.close()
self.run_loop(proto.wait_closed())
self.run_loop(server.wait_closed())

self.addCleanup(cleanup)

Expand Down