OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 def IsDeadlineExceededError(error): | 5 def IsDeadlineExceededError(error): |
6 '''A general way of determining whether |error| is a DeadlineExceededError, | 6 '''A general way of determining whether |error| is a DeadlineExceededError, |
7 since there are 3 different types thrown by AppEngine and we might as well | 7 since there are 3 different types thrown by AppEngine and we might as well |
8 handle them all the same way. For more info see: | 8 handle them all the same way. For more info see: |
9 https://developers.google.com/appengine/articles/deadlineexceedederrors | 9 https://developers.google.com/appengine/articles/deadlineexceedederrors |
10 ''' | 10 ''' |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 logservice = Logservice() | 159 logservice = Logservice() |
160 | 160 |
161 class InMemoryMemcache(object): | 161 class InMemoryMemcache(object): |
162 """An in-memory memcache implementation. | 162 """An in-memory memcache implementation. |
163 """ | 163 """ |
164 def __init__(self): | 164 def __init__(self): |
165 self._namespaces = {} | 165 self._namespaces = {} |
166 | 166 |
167 class Client(object): | 167 class Client(object): |
168 def set_multi_async(self, mapping, namespace='', time=0): | 168 def set_multi_async(self, mapping, namespace='', time=0): |
169 for k, v in mapping.iteritems(): | 169 return _RPC(result=dict( |
170 memcache.set(k, v, namespace=namespace, time=time) | 170 (k, memcache.set(k, v, namespace=namespace, time=time)) |
| 171 for k, v in mapping.iteritems())) |
171 | 172 |
172 def get_multi_async(self, keys, namespace='', time=0): | 173 def get_multi_async(self, keys, namespace='', time=0): |
173 return _RPC(result=dict( | 174 return _RPC(result=dict( |
174 (k, memcache.get(k, namespace=namespace, time=time)) for k in keys)) | 175 (k, memcache.get(k, namespace=namespace, time=time)) for k in keys)) |
175 | 176 |
176 def set(self, key, value, namespace='', time=0): | 177 def set(self, key, value, namespace='', time=0): |
177 self._GetNamespace(namespace)[key] = value | 178 self._GetNamespace(namespace)[key] = value |
178 | 179 |
179 def get(self, key, namespace='', time=0): | 180 def get(self, key, namespace='', time=0): |
180 return self._GetNamespace(namespace).get(key) | 181 return self._GetNamespace(namespace).get(key) |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 def add(self, task): | 304 def add(self, task): |
304 global _task_runner | 305 global _task_runner |
305 if _task_runner: | 306 if _task_runner: |
306 _task_runner(task.GetUrl(), task.GetCommit()) | 307 _task_runner(task.GetUrl(), task.GetCommit()) |
307 return _RPC() | 308 return _RPC() |
308 | 309 |
309 def purge(self): | 310 def purge(self): |
310 return _RPC() | 311 return _RPC() |
311 | 312 |
312 taskqueue = SynchronousTaskQueue() | 313 taskqueue = SynchronousTaskQueue() |
OLD | NEW |