Skip to content

Dependency Injection Initialize depend service for each request #4

Closed

Description

@ItayTheDar

Currently, there is an issue with the package where the service object in the ExamplesController is being instantiated for every request received, rather than being initialized once when the application starts. This can potentially lead to performance problems, especially if the service constructor involves time-consuming operations such as loading data into memory.

Code excerpt illustrating the problem:

@Controller("examples")
class ExamplesController:
    service: ExamplesService = Depends(ExamplesService)
    # ...

Expected Behavior:
Ideally, the service object should be instantiated once during the application's startup process and reused for subsequent requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions