views:

135

answers:

1

I'm using Google AppEngine and the deferred library, with the Mapper class, as described here (with some improvements as in here). In some iterations of the mapper I get the following error:

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

The Mapper usually runs fine, I used to have a higher batch size, so that it would actually hit the DeadlineExceededError, and that was handled correctly.

Just to be sure, I reduced the batch_size to a very low number, so that it never even hits the DeadlineExceededError but I still get the CancelledError.

The stack trace is as follows:

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.

I can't really find a lot of information about this 'explicity cancelled' error, so I was wondering what caused it and how to investigate.

+1  A: 

After a DeadlineExceededError, you are allowed a short amount of grace time to handle the exception, eg defer the remainder of the computation.

If you run out of grace time the CancelledError kicks in.

There should be no way to catch/handle the CancelledError

gnibbler
I suspected that. However, the `Mapper` class was designed to handle these kinds of things. It even has a default batch size of 200. Which things influence the time it takes for `db.put()` to finish/return? I assumed it was only the batch size, so using smaller batches (only 4 !) would make put finish faster and avoid the `CancelledError`. Are there other things that make `db.put()` take longer that I could optimize?? (More indexes? ListProperties? ReferenceProperties?)
Noio