Uh oh!
There was an error while loading. Please reload this page.
GH-79033: Fix asyncio.Server.wait_closed() - #98582
Merged
Merged
Conversation
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. :-(
gvanrossum
commented
Oct 24, 2022
MemberAuthor
Needs test and news entry |
gvanrossum
commented
Nov 22, 2022
MemberAuthor
@kumaraditya303 Can you suggest a test for this? |
kumaraditya303
commented
Nov 23, 2022
Contributor
Something like should work: diff --git a/Lib/test/test_asyncio/test_server.py b/Lib/test/test_asyncio/test_server.py
index 860d62d52e..ceea4059ae 100644
--- a/Lib/test/test_asyncio/test_server.py+++ b/Lib/test/test_asyncio/test_server.py@@ -120,6 +120,26 @@ async def main(srv):
self.loop.run_until_complete(srv.serve_forever())
+class TestServer2(unittest.IsolatedAsyncioTestCase):++ async def test_wait_closed(self):+ async def serve(*args):+ pass++ srv = await asyncio.start_server(serve, socket_helper.HOSTv4, 0)++ # active count = 0+ wait = asyncio.create_task(srv.wait_closed())+ await asyncio.sleep(0)+ self.assertTrue(wait.done())++ # active count != 0+ srv._attach()+ wait = asyncio.create_task(srv.wait_closed())+ await asyncio.sleep(0)+ self.assertFalse(wait.done())++
@unittest.skipUnless(hasattr(asyncio, 'ProactorEventLoop'), 'Windows only')
class ProactorStartServerTests(BaseStartServer, unittest.TestCase):
Creating a test with an actual client seems rather flaky as it requires a heavy load on server so will be unreliable. |
gvanrossum
commented
Nov 23, 2022
MemberAuthor
Thanks! |
gvanrossum
commented
Nov 24, 2022
MemberAuthor
Let’s not backport, I fear it will surprise some users since it never worked. |
This was referenced Sep 27, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wait_closed() 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. :-(