77 skip_tests = False
88
99import asyncio
10+ import sys
1011import unittest
1112import weakref
1213
@@ -48,6 +49,14 @@ async def test():
4849 self .loop .run_until_complete (runner .cleanup ())
4950
5051 def test_aiohttp_graceful_shutdown (self ):
52+ if self .implementation == 'asyncio' and sys .version_info >= (3 , 12 , 0 ):
53+ # In Python 3.12.0, asyncio.Server.wait_closed() waits for all
54+ # existing connections to complete, before aiohttp sends
55+ # on_shutdown signals.
56+ # https://github.com/aio-libs/aiohttp/issues/7675#issuecomment-1752143748
57+ # https://github.com/python/cpython/pull/98582
58+ raise unittest .SkipTest ('bug in aiohttp: #7675' )
59+
5160 async def websocket_handler (request ):
5261 ws = aiohttp .web .WebSocketResponse ()
5362 await ws .prepare (request )
@@ -73,7 +82,12 @@ async def on_shutdown(app):
7382
7483 runner = aiohttp .web .AppRunner (app )
7584 self .loop .run_until_complete (runner .setup ())
76- site = aiohttp .web .TCPSite (runner , '0.0.0.0' , '0' )
85+ site = aiohttp .web .TCPSite (
86+ runner ,
87+ '0.0.0.0' ,
88+ 0 ,
89+ shutdown_timeout = 0.1 , # https://github.com/aio-libs/aiohttp/pull/7188
90+ )
7791 self .loop .run_until_complete (site .start ())
7892 port = site ._server .sockets [0 ].getsockname ()[1 ]
7993
@@ -90,7 +104,7 @@ async def client():
90104 async def stop ():
91105 await asyncio .sleep (0.1 )
92106 try :
93- await asyncio .wait_for (runner .cleanup (), timeout = 0.1 )
107+ await asyncio .wait_for (runner .cleanup (), timeout = 0.5 )
94108 finally :
95109 try :
96110 client_task .cancel ()
0 commit comments