8000 Do not set future if already done by dbrattli · Pull Request #193 · dbrattli/Expression · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Do not set future if already done #193

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Changes from all commits
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
9 changes: 6 additions & 3 deletions expression/core/aiotools.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@ def from_continuations(callback: Callbacks[_TSource]) -> Awaitable[_TSource]:
future: "Future[_TSource]" = asyncio.Future()

def done(value: _TSource) -> None:
future.set_result(value)
if not future.done():
future.set_result(value)

def error(err: Exception) -> None:
future.set_exception(err)
if not future.done():
future.set_exception(err)

def cancel(_: OperationCanceledError) -> None:
future.cancel()
if not future.done():
future.cancel()

callback(done, error, cancel)
return future
Expand Down
0