Skip to content

Bugfix: executor doesn't propagate exception from task that awaited a future (backport #1643)#1651

Open
mergify[bot] wants to merge 1 commit into
kiltedfrom
mergify/bp/kilted/pr-1643
Open

Bugfix: executor doesn't propagate exception from task that awaited a future (backport #1643)#1651
mergify[bot] wants to merge 1 commit into
kiltedfrom
mergify/bp/kilted/pr-1643

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify Bot commented Apr 18, 2026

Fixes #1642

Changes

A task now registers itself on the awaited future via new Future._add_waiting_task.
The executor then dispatches the same Task object and sees its exception through handler.exception() as intended.

  • Future._callbacks now holds Union[Callable, Task]
  • _schedule_or_invoke_done_callbacks handles Task entries through executor._call_task_in_next_spin.
  • _wait_for_ready_callbacks skips tasks that were cancelled or completed between being queued and being popped.
  • A warnings.warn fires if a waiting Task is dropped because the executor weakref could not be resolved.
    This is an automatic backport of pull request Bugfix: executor doesn't propagate exception from task that awaited a future #1643 done by Mergify.

… future (#1643)

* Schedule the original task when task awaits a future

Signed-off-by: Nadav Elkabets <elnadav12@gmail.com>

* Add MultiThreadedExecutor to test

Signed-off-by: Nadav Elkabets <elnadav12@gmail.com>

* Add tests for awaiting a done future and task cancellation during await

Signed-off-by: Nadav Elkabets <elnadav12@gmail.com>

* Removed unused variable

Signed-off-by: Nadav Elkabets <elnadav12@gmail.com>

---------

Signed-off-by: Nadav Elkabets <elnadav12@gmail.com>
(cherry picked from commit aac0ebb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants