MCPcopy Index your code
hub / github.com/python/cpython / test_wait_closed_race

Method test_wait_closed_race

Lib/test/test_asyncio/test_server.py:168–188  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

166 await srv.wait_closed() # Return immediately
167
168 async def test_wait_closed_race(self):
169 # Test a regression in 3.12.0, should be fixed in 3.12.1
170 async def serve(rd, wr):
171 try:
172 await rd.read()
173 finally:
174 wr.close()
175 await wr.wait_closed()
176
177 srv = await asyncio.start_server(serve, socket_helper.HOSTv4, 0)
178 self.addCleanup(srv.close)
179
180 task = asyncio.create_task(srv.wait_closed())
181 await asyncio.sleep(0)
182 self.assertFalse(task.done())
183 addr = srv.sockets[0].getsockname()
184 (rd, wr) = await asyncio.open_connection(addr[0], addr[1])
185 loop = asyncio.get_running_loop()
186 loop.call_soon(srv.close)
187 loop.call_soon(wr.close)
188 await srv.wait_closed()
189
190 async def test_close_clients(self):
191 async def serve(rd, wr):

Callers

nothing calls this directly

Calls 9

addCleanupMethod · 0.80
assertFalseMethod · 0.80
start_serverMethod · 0.45
create_taskMethod · 0.45
wait_closedMethod · 0.45
sleepMethod · 0.45
doneMethod · 0.45
getsocknameMethod · 0.45
call_soonMethod · 0.45

Tested by

no test coverage detected