Skip to content

Commit 053f426

Browse files
committed
Revert pythonGH-21894 as not valid solution for bpo-37658
1 parent acb1522 commit 053f426

File tree

2 files changed

+6
-25
lines changed

2 files changed

+6
-25
lines changed

Lib/asyncio/tasks.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -433,15 +433,12 @@ async def wait_for(fut, timeout):
433433
try:
434434
await waiter
435435
except exceptions.CancelledError:
436-
if fut.done():
437-
return fut.result()
438-
else:
439-
fut.remove_done_callback(cb)
440-
# We must ensure that the task is not running
441-
# after wait_for() returns.
442-
# See https://bugs.python.org/issue32751
443-
await _cancel_and_wait(fut, loop=loop)
444-
raise
436+
fut.remove_done_callback(cb)
437+
# We must ensure that the task is not running
438+
# after wait_for() returns.
439+
# See https://bugs.python.org/issue32751
440+
await _cancel_and_wait(fut, loop=loop)
441+
raise
445442

446443
if fut.done():
447444
return fut.result()

Lib/test/test_asyncio/test_tasks.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,22 +1147,6 @@ def gen():
11471147
res = loop.run_until_complete(task)
11481148
self.assertEqual(res, "ok")
11491149

1150-
def test_wait_for_cancellation_race_condition(self):
1151-
def gen():
1152-
yield 0.1
1153-
yield 0.1
1154-
yield 0.1
1155-
yield 0.1
1156-
1157-
loop = self.new_test_loop(gen)
1158-
1159-
fut = self.new_future(loop)
1160-
loop.call_later(0.1, fut.set_result, "ok")
1161-
task = loop.create_task(asyncio.wait_for(fut, timeout=1))
1162-
loop.call_later(0.1, task.cancel)
1163-
res = loop.run_until_complete(task)
1164-
self.assertEqual(res, "ok")
1165-
11661150
def test_wait_for_waits_for_task_cancellation(self):
11671151
loop = asyncio.new_event_loop()
11681152
self.addCleanup(loop.close)

0 commit comments

Comments
 (0)