Skip to content

Commit

Permalink
fix: correct FastAPI with new state
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancetnik committed Dec 12, 2024
1 parent b84c032 commit cddf8de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions faststream/_internal/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
from faststream._internal.constants import EMPTY
from faststream._internal.context import ContextRepo
from faststream._internal.log import logger
from faststream._internal.state import (
from faststream._internal.state import DIState
from faststream._internal.state.application import (
ApplicationState,
BasicApplicationState,
DIState,
RunningApplicationState,
)
from faststream._internal.state.broker import OuterBrokerState
Expand Down Expand Up @@ -103,7 +104,7 @@ def _init_setupable_( # noqa: PLW3201

serializer = PydanticSerializer()

self._state = BasicApplicationState(
self._state: ApplicationState = BasicApplicationState(
di_state=DIState(
use_fastdepends=True,
get_dependent=None,
Expand Down Expand Up @@ -171,6 +172,10 @@ def __init__(
else:
self.lifespan_context = fake_context

@property
def running(self) -> bool:
return self._state.running

@abstractmethod
def exit(self) -> None:
"""Stop application manually."""
Expand Down Expand Up @@ -278,7 +283,7 @@ async def _shutdown_logging(
"FastStream app shut down gracefully.",
)

# Setvice methods
# Service methods

def _log(self, level: int, message: str) -> None:
if self.logger is not None:
Expand Down Expand Up @@ -328,7 +333,3 @@ def after_shutdown(
apply_types(to_async(func), context__=self.context)
)
return func

@property
def running(self) -> bool:
return self._state.running
2 changes: 1 addition & 1 deletion faststream/_internal/fastapi/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def wrapper(
response_model_exclude_defaults=response_model_exclude_defaults,
response_model_exclude_none=response_model_exclude_none,
provider_factory=self._get_dependencies_overides_provider,
state=self._state,
state=self._state.di_state,
)

return wrapper
Expand Down

0 comments on commit cddf8de

Please sign in to comment.