Reputation: 13376
I have a django 1.5 running on Google App Engine using the djangoappengine
module for the stitching.
Everything works fine, except that about a half of the calls to /_ah/queue/deferred raise the following import error:
Traceback (most recent call last):
File "..../third_party/djangoappengine/deferred/handler.py", line 2, in <module>
from djangoappengine import main
ImportError: No module named djangoappengine
As you can see, the djangoappengine module sits inside the third_party
directory, and this directory is added to sys.path
in the appengine_config.py
file, so there shouldn't be any problems doing from djangoappengine import main
:
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'third_party'))
The relevant line in app.yaml
is:
handlers:
- url: /_ah/queue/deferred
script: third_party/djangoappengine/deferred/handler.py
login: admin
What is causing these sporadic import errors? Am I doing something wrong? Maybe there's an import loop I'm not aware of?
Upvotes: 6
Views: 394
Reputation: 13376
Found out that my code used old CGI interface instead of the newer WSGI. I Fixed this and the problem didn't return since.
Updated app.yaml
:
handlers:
- url: /_ah/queue/deferred
script: djangoappengine.deferred.handler.application
login: admin
Upvotes: 2
Reputation: 2542
The deffer library has been known to do some funky things with 3rd party imports. It has something to do with if the deferred task loads a new instance 3rd party libs are slow to get loaded. You have 2 options (with a 3rd I'm not sure will work)
Upvotes: 1