如何修复发送到未初始化实例的延迟任务?
How to fix deferred tasks being sent to not initialized instance?
我的 Google AppEngine 网站使用延迟任务来完成大量额外工作。有时,延迟任务的数量会导致创建新实例。发生这种情况时,委托给这个新实例的所有任务都会失败,因为它们在实例有机会初始化之前就被发送到了那里。如果在任务进入之前已经启动了足够多的实例,则不会出现问题。
这是其中一项失败任务的示例:
Permanent failure attempting to execute task (/.../google/appengine/ext/deferred/deferred.py:327)
Traceback (most recent call last):
File "/.../google/appengine/ext/deferred/deferred.py", line 318, in post
self.run_from_request()
File "/.../google/appengine/ext/deferred/deferred.py", line 313, in run_from_request
run(self.request.body)
File "/.../google/appengine/ext/deferred/deferred.py", line 153, in run
raise PermanentTaskFailure(e)
PermanentTaskFailure: No module named django
有没有办法告诉延迟系统等到实例完全初始化后再向它发送任务?我正在为这个问题脱发。
GAE warmup requests 的设计正是为了做到这一点:
Loading your app's code to a new instance can result in loading
requests. Loading requests can result in increased request latency
for your users, but you can avoid this latency using warmup
requests. Warmup requests load your app's code into a new instance
before any live requests reach that instance.
您只需要:
我的 Google AppEngine 网站使用延迟任务来完成大量额外工作。有时,延迟任务的数量会导致创建新实例。发生这种情况时,委托给这个新实例的所有任务都会失败,因为它们在实例有机会初始化之前就被发送到了那里。如果在任务进入之前已经启动了足够多的实例,则不会出现问题。
这是其中一项失败任务的示例:
Permanent failure attempting to execute task (/.../google/appengine/ext/deferred/deferred.py:327)
Traceback (most recent call last):
File "/.../google/appengine/ext/deferred/deferred.py", line 318, in post
self.run_from_request()
File "/.../google/appengine/ext/deferred/deferred.py", line 313, in run_from_request
run(self.request.body)
File "/.../google/appengine/ext/deferred/deferred.py", line 153, in run
raise PermanentTaskFailure(e)
PermanentTaskFailure: No module named django
有没有办法告诉延迟系统等到实例完全初始化后再向它发送任务?我正在为这个问题脱发。
GAE warmup requests 的设计正是为了做到这一点:
Loading your app's code to a new instance can result in loading requests. Loading requests can result in increased request latency for your users, but you can avoid this latency using warmup requests. Warmup requests load your app's code into a new instance before any live requests reach that instance.
您只需要: