Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables users to retrieve the result of tasks created via app.add_task() by adding a return statement to the internal task wrapper. Previously, task results were discarded even though the Task object itself was returned.
Key changes:
- Modified
_prep_task()internal wrapper to return the awaited task result - Added comprehensive tests for both direct coroutine and callable task patterns
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| sanic/app.py | Added return statement in the _prep_task method's internal do() coroutine to preserve and propagate task results |
| tests/test_tasks.py | Added two new test cases verifying that task results can be retrieved via both await task and task.result() for coroutines and callables |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3114 +/- ##
=========================================
Coverage 87.893% 87.893%
=========================================
Files 105 105
Lines 8078 8078
Branches 1281 1281
=========================================
Hits 7100 7100
Misses 671 671
Partials 307 307 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Closes #3090
When creating a task from the Sanic app, we return the Asyncio task so that we can call the result later.