Skip to content
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

Add async resolve for DI Container #497

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion blacksheep/server/bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
)
from urllib.parse import unquote
from uuid import UUID
import inspect

from dateutil.parser import parse as dateutil_parser
from guardpost import Identity
Expand Down Expand Up @@ -811,7 +812,10 @@ async def get_value(self, request: Request) -> Any:
scope = None
assert self.services is not None
try:
return self.services.resolve(self.expected_type, scope)
if inspect.iscoroutinefunction(self.services.resolve):
return await self.services.resolve(self.expected_type, scope)
else:
return self.services.resolve(self.expected_type, scope)
except CannotResolveTypeException:
return None

Expand Down