You are absolutely correct that the code is not handling db.Timeout
exceptions correctly. When I wrote the recipe, I could not simulate
Timeouts on the production datastore, so I wrote some code to randomly
raise db.Timeouts and tested that the exponential backoff worked
well. Today, after load testing with 'ab' to hammer a test app in
production, I could still not simulate a db.Timeout, but I could
produce some TransactionFailedErrors and instead attempted to catch
and retry those. It turns out apiproxy_stub_map.MakeSyncCall does not
raise db.Timeout or db.TransactionFailedError, it raises a lower level
Exception. The recipe is now updated in the cookbook to catch the
correct low level exception.
http://appengine-cookbook.appspot.com/recipe/autoretry-datastore-timeouts
Under load, I can see the retries in my log output. If you are able
to consistently produce db.Timeouts in production, please let me know
that it is working for you too.
Thanks for the helpful feedback,
Robin