0

I'm facing a random DeadlineExceededError exception when writing to the response. Here is my handler:

class MyHandler(webapp2.RequestHandler):
    def get(self):
         result = [{'id':1},{'id':2}]
         json_result = json.encode(result)
         self.response.write(json_result)

The log says:

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 266, in Handle
    result = handler(dict(self._environ), self._StartResponse)
  File "/base/data/home/apps/s~ynhac-net/1.370047219851726476/engineauth/middleware.py", line 154, in __call__
    resp = req.get_response(self.app)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webob-1.1.1/webob/request.py", line 1086, in get_response
    application, catch_exc_info=False)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webob-1.1.1/webob/request.py", line 1058, in call_application
    output.extend(app_iter)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/appstats/recording.py", line 1286, in appstats_wsgi_wrapper
    end_recording(status)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/appstats/recording.py", line 1410, in end_recording
    rec.save()
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/appstats/recording.py", line 654, in save
    key, len_part, len_full = self._save()
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/appstats/recording.py", line 678, in _save
    namespace=config.KEY_NAMESPACE)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/memcache/__init__.py", line 1008, in set_multi
    namespace=namespace)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/memcache/__init__.py", line 907, in _set_multi_with_policy
    status_dict = rpc.get_result()
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 612, in get_result
    return self.__get_result_hook(self)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/memcache/__init__.py", line 974, in __set_with_policy_hook
    rpc.check_success()
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 583, in check_success
    self.__stubmap.GetPostCallHooks().Call(self.__service, self.__method,
DeadlineExceededError

I have no clue where to look into since it is a random issue. Please help :)

Cuong Thai
  • 1,165
  • 1
  • 11
  • 24
  • You have appstats enabled. Have a look you are probably starting a new instance with this request. If the instance takes too long to start and it's processing apppstats then you could run into a DeadlineExceededError. – Tim Hoffman Sep 08 '13 at 06:02
  • Correct, i'm using appstas. I noticed that I only process data within 1 second, but when it comes to the response, it takes 1 minute! and throws this error... – Cuong Thai Sep 08 '13 at 06:07
  • Might be worth adding a python tag. – miltonb Sep 08 '13 at 06:22
  • But is this error occurring on a startup or every request. – Tim Hoffman Sep 08 '13 at 07:44
  • It occurs when the instance is running. When I tried to request it again, the problem is gone! It affects 3 apis now. – Cuong Thai Sep 08 '13 at 12:49
  • I notice that this happens because of appstats memcache.set_multi in recording.py – Cuong Thai Sep 22 '13 at 07:51

0 Answers0