I have a package called jiva_tasks that I am trying to import via celery (using the CELERY_IMPORTS celeryconfig attribute). The import operation used by celery is as follows:
__import__(module, [], [], [''])
Oddly enough, when this syntax is used, the module receives the import twice, once as jiva_tasks and another time as jiva_tasks. (with a period at the end). Now there are good chances that celery should be held in globals, and not in an empty list, but this seems to me broken. It seems strange that even if incorrect arguments are given, __import__ will import something that is not a valid python module name.
I know that the way to fix this is to go to globals , but I want to understand why I get this result. Is this a mistake or is there something I donβt understand about how __import__ works?
Update : it also works fine if I use importlib .
Update 2 . Here sys.meta_path and sys.import_path right before the __import__ line:
>>> sys.meta_path [] >>> sys.path_hooks [<type 'zipimport.zipimporter'>]
It does not seem to me that there is anything unusual. However, I only now realized that the package I import is installed using the setuptools development team. Does it matter?
source share