Skip to content

How to handle resources? #251

Description

@mario-gazzara

Hi all,

I come from the dependency injector library, and recently I've been exploring another library to see if it could potentially replace dependency injector altogether.

I find it quite interesting, but I still have some doubts. For instance, how can I manage resource releases with this new library?

Let's consider a scenario where I have a client that needs to be released in a certain time (out of scope, raising an exception or at the end of a job to clean all resources):

def get_sqs_client_gen() -> Generator[SQSClient, None, None]:
    client: Optional[SQSClient] = None

    try:
        client = get_sqs_client()
        yield client
    finally:
        if client:
            client.close()

Is there a provider within this library to handle such resources, or should I manually handle acquisition and release by passing it as a context manager?

Thank you for your support!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions