File tree Expand file tree Collapse file tree 2 files changed +24
-26
lines changed Expand file tree Collapse file tree 2 files changed +24
-26
lines changed Original file line number Diff line number Diff line change @@ -2188,32 +2188,6 @@ def test_task_source_traceback(self):
2188
2188
'test_task_source_traceback' ))
2189
2189
self .loop .run_until_complete (task )
2190
2190
2191
- def _test_cancel_wait_for (self , timeout ):
2192
- loop = asyncio .new_event_loop ()
2193
- self .addCleanup (loop .close )
2194
-
2195
- async def blocking_coroutine ():
2196
- fut = self .new_future (loop )
2197
- # Block: fut result is never set
2198
- await fut
2199
-
2200
- task = loop .create_task (blocking_coroutine ())
2201
-
2202
- wait = loop .create_task (asyncio .wait_for (task , timeout ))
2203
- loop .call_soon (wait .cancel )
2204
-
2205
- self .assertRaises (asyncio .CancelledError ,
2206
- loop .run_until_complete , wait )
2207
-
2208
- # Python issue #23219: cancelling the wait must also cancel the task
2209
- self .assertTrue (task .cancelled ())
2210
-
2211
- def test_cancel_blocking_wait_for (self ):
2212
- self ._test_cancel_wait_for (None )
2213
-
2214
- def test_cancel_wait_for (self ):
2215
- self ._test_cancel_wait_for (60.0 )
2216
-
2217
2191
def test_cancel_gather_1 (self ):
2218
2192
"""Ensure that a gathering future refuses to be cancelled once all
2219
2193
children are done"""
Original file line number Diff line number Diff line change @@ -264,6 +264,30 @@ async def inner():
264
264
265
265
self .assertEqual (await inner_task , 42 )
266
266
267
+ async def _test_cancel_wait_for (self , timeout ):
268
+ loop = asyncio .get_running_loop ()
269
+
270
+ async def blocking_coroutine ():
271
+ fut = loop .create_future ()
272
+ # Block: fut result is never set
273
+ await fut
274
+
275
+ task = asyncio .create_task (blocking_coroutine ())
276
+
277
+ wait = asyncio .create_task (asyncio .wait_for (task , timeout ))
278
+ loop .call_soon (wait .cancel )
279
+
280
+ with self .assertRaises (asyncio .CancelledError ):
281
+ await wait
282
+
283
+ # Python issue #23219: cancelling the wait must also cancel the task
284
+ self .assertTrue (task .cancelled ())
285
+
286
+ async def test_cancel_blocking_wait_for (self ):
287
+ await self ._test_cancel_wait_for (None )
288
+
289
+ async def test_cancel_wait_for (self ):
290
+ await self ._test_cancel_wait_for (60.0 )
267
291
268
292
269
293
if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments