7
7
skip_tests = False
8
8
9
9
import asyncio
10
+ import sys
10
11
import unittest
11
12
import weakref
12
13
@@ -48,6 +49,14 @@ async def test():
48
49
self .loop .run_until_complete (runner .cleanup ())
49
50
50
51
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
+
51
60
async def websocket_handler (request ):
52
61
ws = aiohttp .web .WebSocketResponse ()
53
62
await ws .prepare (request )
@@ -73,7 +82,12 @@ async def on_shutdown(app):
73
82
74
83
runner = aiohttp .web .AppRunner (app )
75
84
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
+ )
77
91
self .loop .run_until_complete (site .start ())
78
92
port = site ._server .sockets [0 ].getsockname ()[1 ]
79
93
@@ -90,7 +104,7 @@ async def client():
90
104
async def stop ():
91
105
await asyncio .sleep (0.1 )
92
106
try :
93
- await asyncio .wait_for (runner .cleanup (), timeout = 0.1 )
107
+ await asyncio .wait_for (runner .cleanup (), timeout = 0.5 )
94
108
finally :
95
109
try :
96
110
client_task .cancel ()
0 commit comments