@@ -76,7 +76,7 @@ async def resolve(*_args):
7676 # raises TimeoutError if not parallel
7777 awaitable_result = execute (schema , ast )
7878 assert isinstance (awaitable_result , Awaitable )
79- result = await asyncio .wait_for (awaitable_result , 1.0 )
79+ result = await asyncio .wait_for (awaitable_result , 1 )
8080
8181 assert result == ({"foo" : True , "bar" : True }, None )
8282
@@ -125,7 +125,7 @@ async def resolve_list(*args):
125125 # raises TimeoutError if not parallel
126126 awaitable_result = execute (schema , ast )
127127 assert isinstance (awaitable_result , Awaitable )
128- result = await asyncio .wait_for (awaitable_result , 1.0 )
128+ result = await asyncio .wait_for (awaitable_result , 1 )
129129
130130 assert result == ({"foo" : [True , True ]}, None )
131131
@@ -188,15 +188,15 @@ async def is_type_of_baz(obj, *_args):
188188 # raises TimeoutError if not parallel
189189 awaitable_result = execute (schema , ast )
190190 assert isinstance (awaitable_result , Awaitable )
191- result = await asyncio .wait_for (awaitable_result , 1.0 )
191+ result = await asyncio .wait_for (awaitable_result , 1 )
192192
193193 assert result == (
194194 {"foo" : [{"foo" : "bar" , "foobar" : 1 }, {"foo" : "baz" , "foobaz" : 2 }]},
195195 None ,
196196 )
197197
198198 @pytest .mark .asyncio
199- async def cancel_on_exception ():
199+ async def cancel_selection_sets_on_exception ():
200200 barrier = Barrier (2 )
201201 completed = False
202202
@@ -222,13 +222,61 @@ async def fail(*_args):
222222
223223 awaitable_result = execute (schema , ast )
224224 assert isinstance (awaitable_result , Awaitable )
225- result = await asyncio .wait_for (awaitable_result , 1.0 )
225+ result = await asyncio .wait_for (awaitable_result , 1 )
226226
227227 assert result == (
228228 None ,
229229 [{"message" : "Oops" , "locations" : [(1 , 2 )], "path" : ["foo" ]}],
230230 )
231231
232+ assert not completed
233+ 234+ # Unblock succeed() and check that it does not complete
235+ await barrier .wait ()
236+ await asyncio .sleep (0 )
237+ assert not completed
238+ 239+ @pytest .mark .asyncio
240+ async def cancel_lists_on_exception ():
241+ barrier = Barrier (2 )
242+ completed = False
243+ 244+ async def succeed (* _args ):
245+ nonlocal completed
246+ await barrier .wait ()
247+ completed = True # pragma: no cover
248+ 249+ async def fail (* _args ):
250+ raise RuntimeError ("Oops" )
251+ 252+ async def resolve_list (* args ):
253+ return [fail (* args ), succeed (* args )]
254+ 255+ schema = GraphQLSchema (
256+ GraphQLObjectType (
257+ "Query" ,
258+ {
259+ "foo" : GraphQLField (
260+ GraphQLList (GraphQLNonNull (GraphQLBoolean )),
261+ resolve = resolve_list ,
262+ )
263+ },
264+ )
265+ )
266+ 267+ ast = parse ("{foo}" )
268+ 269+ awaitable_result = execute (schema , ast )
270+ assert isinstance (awaitable_result , Awaitable )
271+ result = await asyncio .wait_for (awaitable_result , 1 )
272+ 273+ assert result == (
274+ {"foo" : None },
275+ [{"message" : "Oops" , "locations" : [(1 , 2 )], "path" : ["foo" , 0 ]}],
276+ )
277+ 278+ assert not completed
279+ 232280 # Unblock succeed() and check that it does not complete
233281 await barrier .wait ()
234282 await asyncio .sleep (0 )
0 commit comments