File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -237,6 +237,34 @@ async def inner():
237
237
with self .assertRaises (FooException ):
238
238
await foo ()
239
239
240
+ @unittest .skip ("TODO" )
241
+ async def test_wait_for_self_cancellation (self ):
242
+ async def inner ():
243
+ try :
244
+ await asyncio .sleep (0.3 )
245
+ except asyncio .CancelledError :
246
+ try :
247
+ await asyncio .sleep (0.3 )
248
+ except asyncio .CancelledError :
249
+ await asyncio .sleep (0.3 )
250
+
251
+ return 42
252
+
253
+ inner_task = asyncio .create_task (inner ())
254
+
255
+ wait = asyncio .wait_for (inner_task , timeout = 0.1 )
256
+
257
+ # Test that wait_for itself is properly cancellable
258
+ # even when the initial task holds up the initial cancellation.
259
+ task = asyncio .create_task (wait )
260
+ await asyncio .sleep (0.2 )
261
+ task .cancel ()
262
+
263
+ with self .assertRaises (asyncio .CancelledError ):
264
+ await task
265
+
266
+ self .assertEqual (await inner_task , 42 )
267
+
240
268
async def _test_cancel_wait_for (self , timeout ):
241
269
loop = asyncio .get_running_loop ()
242
270
You can’t perform that action at this time.
0 commit comments