support both asyncio and blocking modes with different abstractions#178
Merged
achille-roussel merged 1 commit intoaiohttp-2from Jun 19, 2024
Merged
support both asyncio and blocking modes with different abstractions#178achille-roussel merged 1 commit intoaiohttp-2from
achille-roussel merged 1 commit intoaiohttp-2from
Conversation
Signed-off-by: Achille Roussel <[email protected]>
chriso
approved these changes
Jun 19, 2024
| Example: | ||
|
|
||
| import fastapi | ||
| from dispatch.asyncio.fastapi import Dispatch |
Contributor
Contributor
Author
There was a problem hiding this comment.
I asked myself the same question... I know FastAPI is natively async, but their home page shows examples with non-async code (https://fastapi.tiangolo.com/), which makes me think it's probably a popular default.
The package name with asyncio is also self-explanatory, but using something like dispatch.blocking.fastapi would somewhat look like inventing a new name that may not be as clear to developers unfamiliar with the concept.
Tough call 🤷
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.
Based on #176, this PR is an example of how we could change our internals to support both blocking and asyncio modes.
An important point here is we retain end-to-end type safety via annotations, since mypy is able to differentiate types (e.g.,
AsyncFunctionandBlockingFunction).