File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -1009,20 +1009,15 @@ def gen():
1009
1009
self .assertEqual (res , "ok" )
1010
1010
1011
1011
def test_wait_for_cancellation_race_condition (self ):
1012
- def gen ():
1013
- yield 0.1
1014
- yield 0.1
1015
- yield 0.1
1016
- yield 0.1
1012
+ async def inner ():
1013
+ await asyncio .wait_for (asyncio .sleep (1 ), timeout = 2 )
1014
+ return 1
1017
1015
1018
- loop = self .new_test_loop (gen )
1016
+ async def main ():
1017
+ result = await asyncio .wait_for (inner (), timeout = 1 )
1018
+ assert result == 1
1019
1019
1020
- fut = self .new_future (loop )
1021
- loop .call_later (0.1 , fut .set_result , "ok" )
1022
- task = loop .create_task (asyncio .wait_for (fut , timeout = 1 ))
1023
- loop .call_later (0.1 , task .cancel )
1024
- res = loop .run_until_complete (task )
1025
- self .assertEqual (res , "ok" )
1020
+ asyncio .run (main ())
1026
1021
1027
1022
def test_wait_for_waits_for_task_cancellation (self ):
1028
1023
loop = asyncio .new_event_loop ()
You can’t perform that action at this time.
0 commit comments