GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||
GeezerVison is showing github.com — GH-79033: Fix asyncio.Server.wait_closed() by gvanrossum · Pull Request #98582 · python/cpython Conversation
|
|
Needs test and news entry |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@kumaraditya303 Can you suggest a test for this? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Let’s not backport, I fear it will surprise some users since it never worked. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.