有沒有辦法在執行任務時處理任何軟期限? DeadlineExceededError在執行10分鐘後拋出,我在幾秒鐘後給出一些東西。 我想在任務死亡之前清理一些東西並創建一個新任務。這可能需要幾秒鐘。有沒有辦法通過捕獲任何異常,如約9分鐘來做到這一點。 我知道我可以在9分鐘後手動拋出異常。但是這可以由GAE自動完成嗎?Google App Engine任務截止日期
class FillMtxHandler():
def post(self,index,user,seqlen):
try :
FillMtx(index,user,seqlen)
except DeadlineExceededError:
deferred.defer(self.post,index,user,seqlen)
以上是我的代碼。索引是一個列表,從0開始。它將在FillMtx中遞增。一旦截止日期超出錯誤被拋出,我想繼續索引最後增加的位置。我收到以下錯誤
The API call taskqueue.BulkAdd() was explicitly cancelled.
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 517, in __call__
handler.post(*groups)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 258, in post
run(self.request.body)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 124, in run
return func(*args, **kwds)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 166, in invoke_member
return getattr(obj, membername)(*args, **kwargs)
File "/base/data/home/apps/0xxopdp/3.347813391084738922/fillmtx.py", line 204, in post
deferred.defer(self.post,index,user,seqlen)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 241, in defer
return task.add(queue, transactional=transactional)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/taskqueue/taskqueue.py", line 688, in add
return Queue(queue_name).add(self, transactional=transactional)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/taskqueue/taskqueue.py", line 744, in add
self.__AddTasks(tasks, transactional)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/taskqueue/taskqueue.py", line 770, in __AddTasks
apiproxy_stub_map.MakeSyncCall('taskqueue', 'BulkAdd', request, response)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 86, in MakeSyncCall
return stubmap.MakeSyncCall(service, call, request, response)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 286, in MakeSyncCall
rpc.CheckSuccess()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_rpc.py", line 126, in CheckSuccess
raise self.exception
CancelledError: The API call taskqueue.BulkAdd() was explicitly cancelled.
我發現一個新任務已創建並排隊。但爲什麼GAE仍然會拋出這個錯誤?
我該如何確定在命中硬限制之前將任務添加到任務隊列?我得到了「CancelledError:明確取消了API調用taskqueue.BulkAdd()」,即使已經添加了任務 – Sam 2011-01-22 15:00:29
如果用完寬限時間,CancelledError會啓動。 – systempuntoout 2011-01-22 17:37:44