Add support for async workflow activities#1053
Draft
seherv wants to merge 9 commits into
Draft
Conversation
seherv
commented
May 25, 2026
| f"Activity '{req.name}#{req.taskId}' result is too large to deliver " | ||
| f'(RESOURCE_EXHAUSTED). Failing the activity task: {rpc_error.details()}' | ||
| ) | ||
| failure_res = pb.ActivityResponse( |
Contributor
Author
There was a problem hiding this comment.
This nesting got hard to follow, I needed to refactor this file to understand the logic better.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1053 +/- ##
==========================================
- Coverage 86.63% 82.84% -3.79%
==========================================
Files 84 149 +65
Lines 4473 15017 +10544
==========================================
+ Hits 3875 12441 +8566
- Misses 598 2576 +1978 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
ext/dapr-ext-workflow/dapr/ext/workflow/_durabletask/worker.py:678
- This adds an extra registry lookup (
get_activity) andinspect.iscoroutinefunctioncheck on the hot dispatch path, but_ActivityExecutor._resolve()will look up the activity again during execution. Consider plumbingactivity_fn(and/or anis_asyncflag decided at registration time) through to the executor so each activity work item only does one lookup in total.
activity_handler,
work_item.activityRequest,
stub,
work_item.completionToken,
)
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Comment on lines
+25
to
+37
| def is_async_callable(fn: Any) -> bool: | ||
| """Return True if ``fn`` is async. Catches ``functools.partial`` of coroutines, | ||
| sync decorators that wrap async functions, and callable instances with ``async __call__``. | ||
| """ | ||
| candidate = fn | ||
| while isinstance(candidate, functools.partial): | ||
| candidate = candidate.func | ||
| candidate = inspect.unwrap(candidate) if callable(candidate) else candidate | ||
| if inspect.iscoroutinefunction(candidate): | ||
| return True | ||
| if not inspect.isfunction(candidate) and hasattr(candidate, '__call__'): | ||
| return inspect.iscoroutinefunction(candidate.__call__) | ||
| return False |
Comment on lines
+1145
to
1151
| except RuntimeError as exc: | ||
| # Manager thread pool shut down (worker is tearing down). Treat as transient: | ||
| # the sidecar will re-dispatch the work item once the worker reconnects. | ||
| self._logger.warning( | ||
| f"Could not deliver activity response for '{req.name}#{req.taskId}': " | ||
| f'{exc}. The sidecar will re-dispatch this work item.' | ||
| ) |
| hosts or need per-call timeout isolation, stick with per-call clients. | ||
|
|
||
| ## Re-running the benchmark | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Workflow activities can now be async, and the runtime will automatically dispatch them to the event loop. Sync activities are still dispatched to the thread pool. The user-facing API remains exactly the same.
Also added a benchmark suite to verify performance locally.
Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR will close: #834 #897 #975
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: