Skip to content

Commit 8bb0e0b

Browse files
committed
Remove fallback code as _copy_future_state always expects a concurrent.futures.Future
1 parent 6b76a37 commit 8bb0e0b

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed

Lib/asyncio/futures.py

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -351,36 +351,19 @@ def _set_concurrent_future_state(concurrent, source):
351351
def _copy_future_state(source, dest):
352352
"""Internal helper to copy state from another Future.
353353
354-
The other Future may be a concurrent.futures.Future.
354+
The other Future must be a concurrent.futures.Future.
355355
"""
356356
if dest.cancelled():
357357
return
358358
assert not dest.done()
359-
360-
# Use _get_snapshot for futures that support it
361-
if hasattr(source, '_get_snapshot'):
362-
done, cancelled, result, exception = source._get_snapshot()
363-
assert done
364-
if cancelled:
365-
dest.cancel()
366-
elif exception is not None:
367-
dest.set_exception(_convert_future_exc(exception))
368-
else:
369-
dest.set_result(result)
370-
return
371-
372-
# Traditional fallback needs done check
373-
assert source.done()
374-
if source.cancelled():
359+
done, cancelled, result, exception = source._get_snapshot()
360+
assert done
361+
if cancelled:
375362
dest.cancel()
363+
elif exception is not None:
364+
dest.set_exception(_convert_future_exc(exception))
376365
else:
377-
exception = source.exception()
378-
if exception is not None:
379-
dest.set_exception(_convert_future_exc(exception))
380-
else:
381-
result = source.result()
382-
dest.set_result(result)
383-
366+
dest.set_result(result)
384367

385368
def _chain_future(source, destination):
386369
"""Chain two futures so that when one completes, so does the other.

0 commit comments

Comments
 (0)