Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Context manager support #25

Open
Finistere opened this issue Dec 19, 2020 · 0 comments
Open

Context manager support #25

Finistere opened this issue Dec 19, 2020 · 0 comments
Milestone

Comments

@Finistere
Copy link
Owner

Currently @inject does not support any context manager. It would be great to have something like:

from contextlib import contextmanager
from antidote import inject, resource

@resource
@contextamanger
def database_connection():
    # setup
    yield 'the database'
    # cleanup

@inject(dependencies=dict(db=database_connection))  # or Database @ database_connection like factories ?
def f(db):
    pass
@Finistere Finistere changed the title resources Context manager support Dec 19, 2020
@Finistere Finistere added this to the 2.X milestone Sep 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant