I have a package named jiva_tasks
, which I'm trying to import via celery (using the CELERY_IMPORTS
attribute of celeryconfig. The import statement that celery is using is this:
__import__(module, [], [], [''])
Oddly enough, when this syntax is used, the module gets imported twice, once as jiva_tasks
and another time as jiva_tasks.
(with a period at the end). Now, chances are good that celery should be passing in globals rather than an empty list, but this seems broken to me. It seems odd that even if given the wrong arguments, __import__
would import something that isn't a valid python module name.
I know that the way to fix this is to pass in globals
, but I want to understand why I'm getting this result. Is this a bug, or is there something I don't understand about how __import__
is working?
Update: It also seems to be working fine if I use importlib
.
Update 2: Here's the sys.meta_path
and sys.import_path
right before the __import__
line gets executed:
>>> sys.meta_path
[]
>>> sys.path_hooks
[<type 'zipimport.zipimporter'>]
It doesn't appear to me that there's anything out of the ordinary. However, I just now realized that the package I'm importing is installed using setuptools' develop command. Does that make a difference?