我正在使用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.
我实际上找不到有关“明确取消”错误的很多信息,所以我想知道是什么导致了这个错误,并且如何进行调查。
Mapper
类被设计用来处理这些情况。它甚至有一个默认的批处理大小为200。哪些因素会影响db.put()
完成/返回所需的时间?我认为只有批处理大小,因此使用更小的批处理(仅4个!)将使put完成得更快,并避免CancelledError
。还有其他使db.put()
需要更长时间的因素可以进行优化吗?(更多索引?ListProperties?ReferenceProperties?) - noio