Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PermanentTaskFailure in AppEngine deferred library

I am using App Engine and the deferred library. But every once in a while my task fail with the following error:

Permanent failure attempting to execute task
Traceback (most recent call last):
  File "/base/python_lib/versions/1/google/appengine/ext/deferred/deferred.py", 
    line 256, in post
      run(self.request.body)
  File "/base/python_lib/versions/1/google/appengine/ext/deferred/deferred.py", 
    line 122, in run
      raise PermanentTaskFailure(e)
PermanentTaskFailure: Environment variable DJANGO_SETTINGS_MODULE is undefined.

I found a post saying the solution is to:

from google.appengine.ext.webapp import template 

But I am not using the webapp framework, I'm using Django. What can I try?

like image 968
noio Avatar asked Feb 26 '26 16:02

noio


1 Answers

Errors like this generally occur when your task depends on some Python path manipulation or other jiggery-pokery that isn't being carried out when the first request to a runtime is via deferred. You need to make sure that all your entry points - eg, the module containing the function you're deferring - import a module that does the relevant path manipulation.

Alternatively, you can write your own deferred task handler, which, being part of your framework, will already have the relevant patches applied. For that, simply register the handler and have it call deferred.run(), passing in the complete body of the request.

like image 108
Nick Johnson Avatar answered Mar 01 '26 10:03

Nick Johnson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!