AppEngine“显式取消”错误

4

我正在使用Google AppEngine和延迟库,使用Mapper类,如此处所述(并进行了一些改进,如此处)。在某些迭代中,我会遇到以下错误:

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

映射器通常运行良好,我曾经使用更高的批处理大小,以便它实际上会触发DeadlineExceededError,并且已正确处理。

只是为了确保,我将batch_size减小到非常低的数字,以便它甚至不会触发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

我本来就怀疑这个问题。不过,Mapper类被设计用来处理这些情况。它甚至有一个默认的批处理大小为200。哪些因素会影响db.put()完成/返回所需的时间?我认为只有批处理大小,因此使用更小的批处理(仅4个!)将使put完成得更快,并避免CancelledError。还有其他使db.put()需要更长时间的因素可以进行优化吗?(更多索引?ListProperties?ReferenceProperties?) - noio
有什么想法,“我们怎样才能避免这种情况?” - Femina
我不确定这个答案是否仍然正确。我发现这些异常在任务队列中被抛出(其限制为10分钟),大约在请求的第54秒。 - speedplane

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接