@@ -76,7 +76,7 @@ async def resolve(*_args):
76
76
# raises TimeoutError if not parallel
77
77
awaitable_result = execute (schema , ast )
78
78
assert isinstance (awaitable_result , Awaitable )
79
- result = await asyncio .wait_for (awaitable_result , 1.0 )
79
+ result = await asyncio .wait_for (awaitable_result , 1 )
80
80
81
81
assert result == ({"foo" : True , "bar" : True }, None )
82
82
@@ -125,7 +125,7 @@ async def resolve_list(*args):
125
125
# raises TimeoutError if not parallel
126
126
awaitable_result = execute (schema , ast )
127
127
assert isinstance (awaitable_result , Awaitable )
128
- result = await asyncio .wait_for (awaitable_result , 1.0 )
128
+ result = await asyncio .wait_for (awaitable_result , 1 )
129
129
130
130
assert result == ({"foo" : [True , True ]}, None )
131
131
@@ -188,15 +188,15 @@ async def is_type_of_baz(obj, *_args):
188
188
# raises TimeoutError if not parallel
189
189
awaitable_result = execute (schema , ast )
190
190
assert isinstance (awaitable_result , Awaitable )
191
- result = await asyncio .wait_for (awaitable_result , 1.0 )
191
+ result = await asyncio .wait_for (awaitable_result , 1 )
192
192
193
193
assert result == (
194
194
{"foo" : [{"foo" : "bar" , "foobar" : 1 }, {"foo" : "baz" , "foobaz" : 2 }]},
195
195
None ,
196
196
)
197
197
198
198
@pytest .mark .asyncio
199
- async def cancel_on_exception ():
199
+ async def cancel_selection_sets_on_exception ():
200
200
barrier = Barrier (2 )
201
201
completed = False
202
202
@@ -222,13 +222,61 @@ async def fail(*_args):
222
222
223
223
awaitable_result = execute (schema , ast )
224
224
assert isinstance (awaitable_result , Awaitable )
225
- result = await asyncio .wait_for (awaitable_result , 1.0 )
225
+ result = await asyncio .wait_for (awaitable_result , 1 )
226
226
227
227
assert result == (
228
228
None ,
229
229
[{"message" : "Oops" , "locations" : [(1 , 2 )], "path" : ["foo" ]}],
230
230
)
231
231
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
+
232
280
# Unblock succeed() and check that it does not complete
233
281
await barrier .wait ()
234
282
await asyncio .sleep (0 )
0 commit comments