Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use interfaces in Celery task injections? #24

Open
pete0877 opened this issue Feb 19, 2025 · 0 comments
Open

Is it possible to use interfaces in Celery task injections? #24

pete0877 opened this issue Feb 19, 2025 · 0 comments

Comments

@pete0877
Copy link

I example here for the FastAPI version of what I'm looking to do.

I was hoping this would work, but it does not:

injector = DependencyInjector()
injector.bind({IExternalEmailImportService: ExternalEmailImportService})

@app.task(queue="external_email_import_queue")
def external_email_import_task(import_service: IExternalEmailImportService = PROVIDE):
     ...

IExternalEmailImportService is the interface.
ExternalEmailImportService is the implementation.

I can't seem to subscript PROVIDE like PROVIDE[IExternalEmailImportService] the way it is possible with Provide from magic_di.fastapi.

class IExternalEmailImportService(Protocol):
    @abstractmethod
    async def process(self):
        pass

class ExternalEmailImportService(Connectable):
    pass

.. and I tried this with ExternalEmailImportService inheriting from IExternalEmailImportService (as it should under normal circumstances, especially if I want to do type & method checking for the injeritance).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant