Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-134173: Optimize concurrent.futures→asyncio state transfer with atomic snapshot#134174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kumaraditya303 merged 9 commits intopython:mainfrombdraco:thread_to_asyncio_slow
May 18, 2025
Merged
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Remove fallback code as _copy_future_state always expects a concurren…
…t.futures.Future
  • Loading branch information
@bdraco
bdraco committedMay 18, 2025
commit8bb0e0baf4bb883b99bf90e2f7cd52c74870223e
31 changes: 7 additions & 24 deletionsLib/asyncio/futures.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -351,36 +351,19 @@ def _set_concurrent_future_state(concurrent, source):
def _copy_future_state(source, dest):
"""Internal helper to copy state from another Future.

The other Futuremay be a concurrent.futures.Future.
The other Futuremust be a concurrent.futures.Future.
"""
if dest.cancelled():
return
assert not dest.done()

# Use _get_snapshot for futures that support it
if hasattr(source, '_get_snapshot'):
done, cancelled, result, exception = source._get_snapshot()
assert done
if cancelled:
dest.cancel()
elif exception is not None:
dest.set_exception(_convert_future_exc(exception))
else:
dest.set_result(result)
return

# Traditional fallback needs done check
assert source.done()
if source.cancelled():
done, cancelled, result, exception = source._get_snapshot()
assert done
if cancelled:
dest.cancel()
elif exception is not None:
dest.set_exception(_convert_future_exc(exception))
else:
exception = source.exception()
if exception is not None:
dest.set_exception(_convert_future_exc(exception))
else:
result = source.result()
dest.set_result(result)

dest.set_result(result)

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

[8]ページ先頭

©2009-2025 Movatter.jp