Skip to content

using config in resource return config object instead of value #668

Open
@wiryonolau

Description

@wiryonolau

Hi I want to create a resource using config value that pass from argparse. But somehow it return as config

main.py

container = Container(config={"alimit":100})
container.init_resources()
container.wire(modules=[sys.modules[__name__]])

container.py

def init_semaphore(limit):
    return asyncio.BoundedSemaphore(limit)

class Container(containers.DeclarativeContainer):
    config = providers.Configuration()
    semaphore = providers.Resource(init_semaphore(limit=config.alimit))

I got error from init_semaphore due to limit is a config object instead of the value
How to do this correctly ?

It's not async but should be similar to example in https://python-dependency-injector.ets-labs.org/providers/resource.html

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