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

Compatibility with imp.find_module for celery #25

Open
john-hadron opened this issue Dec 29, 2017 · 1 comment
Open

Compatibility with imp.find_module for celery #25

john-hadron opened this issue Dec 29, 2017 · 1 comment

Comments

@john-hadron
Copy link

john-hadron commented Dec 29, 2017

First, thanks for the great library!

I added celery to the example project you had, and celery's autodiscover_tasks failed to discover my celery tasks.pye files.

Turns out that celery uses the builtin imp package to check if tasks.py exists in all django apps, at app/tasks.py. In particular, it uses imp.find_module() described here https://docs.python.org/2/library/imp.html#imp.find_module

Sadly, imp.find_module doesn't find .pye files, such as tasks.pye.

Celery code: https://github.com/celery/celery/blob/120770929f4a37c5373a378b75b5c41a99702af9/celery/utils/imports.py#L90

My workaround was to use pyconcrete-admin.py ... -i tasks.py and have tasks.py simply star import an encrypted module (as no one will try to find that one ;) ).

Again, no pressure, but it will be great if we could have a hook for that library as well.

I'm just signaling this here, with a keyword Celery in case anyone else tumbles on this issues.

@Falldog Falldog added the bug label Jan 2, 2018
@Falldog
Copy link
Owner

Falldog commented Jan 3, 2018

Per the document about Import Hook(MetaPath) mechanism (pyconcrete implementation)
https://www.python.org/dev/peps/pep-0302/#integration-with-the-imp-module

Basically imp.find_module() can't integrate with Import Hook(MetaPath) by now. If we want to patch imp.find_module() at runtime, I am not sure it's a good idea, need to check all python version implementation about imp.find_module(), need more investigation.

@Falldog Falldog added enhancement and removed bug labels Sep 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants