AppEngine "显式取消"错误

4 投票
1 回答
1694 浏览
提问于 2025-04-15 19:11

我正在使用Google AppEngine和延迟库,配合Mapper类,具体内容可以在这里找到(还有一些改进的内容在这里)。在Mapper的某些运行中,我遇到了以下错误:

CancelledError: The API call datastore_v3.Put() was explicitly cancelled.

通常情况下,Mapper运行得很好,我之前设置的批处理大小比较大,所以会遇到DeadlineExceededError,但这个错误处理得还不错。

为了确保问题不再出现,我把批处理大小调得很小,这样就不会再遇到DeadlineExceededError了,但我还是收到了CancelledError

错误的堆栈信息如下:

File "utils.py", line 114, in _continue
  self._batch_write()
File "utils.py", line 76, in _batch_write
  db.put(self.to_put)
File "/google/appengine/ext/db/__init__.py", line 1238, in put
  keys = datastore.Put(entities, rpc=rpc)
File "/google/appengine/api/datastore.py", line 255, in Put
  'datastore_v3', 'Put', req, datastore_pb.PutResponse(), rpc)
File "/google/appengine/api/datastore.py", line 177, in _MakeSyncCall
  rpc.check_success()
File "/google/appengine/api/apiproxy_stub_map.py", line 474, in check_success
  self.__rpc.CheckSuccess()
File "/google/appengine/api/apiproxy_rpc.py", line 126, in CheckSuccess
  raise self.exception
CancelledError: The API call datastore_v3.Put() was explicitly cancelled.

我找不到很多关于这个“明确取消”的错误的信息,所以我想知道是什么原因导致的,以及该如何调查。

1 个回答

1

在遇到一个叫做 DeadlineExceededError 的错误后,你会有一点额外的时间来处理这个错误,比如说可以暂时停止剩下的计算。

如果你用完了这个额外的时间,就会出现另一个错误,叫做 CancelledError

而且,CancelledError 是无法被捕获或处理的。

撰写回答