| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 from appengine_wrappers import db, IsDevServer | 5 from appengine_wrappers import db, IsDevServer |
| 6 from datastore_models import PersistentObjectStoreItem | 6 from datastore_models import PersistentObjectStoreItem |
| 7 from future import Future | 7 from future import Future |
| 8 import logging | |
| 9 from object_store import ObjectStore | 8 from object_store import ObjectStore |
| 10 | 9 |
| 11 class _AsyncGetFuture(object): | 10 class _AsyncGetFuture(object): |
| 12 def __init__(self, object_store, keys): | 11 def __init__(self, object_store, keys): |
| 13 self._futures = dict( | 12 self._futures = dict( |
| 14 (k, db.get_async( | 13 (k, db.get_async( |
| 15 PersistentObjectStoreItem.CreateKey(object_store._namespace, k))) | 14 PersistentObjectStoreItem.CreateKey(object_store._namespace, k))) |
| 16 for k in keys) | 15 for k in keys) |
| 17 | 16 |
| 18 def Get(self): | 17 def Get(self): |
| (...skipping 22 matching lines...) Expand all Loading... |
| 41 | 40 |
| 42 def DelMulti(self, keys): | 41 def DelMulti(self, keys): |
| 43 futures = [] | 42 futures = [] |
| 44 for key in keys: | 43 for key in keys: |
| 45 futures.append(db.delete_async( | 44 futures.append(db.delete_async( |
| 46 PersistentObjectStoreItem.CreateKey(self._namespace, key))) | 45 PersistentObjectStoreItem.CreateKey(self._namespace, key))) |
| 47 # If running the dev server, the futures don't complete until the server is | 46 # If running the dev server, the futures don't complete until the server is |
| 48 # *quitting*. This is annoying. Flush now. | 47 # *quitting*. This is annoying. Flush now. |
| 49 if IsDevServer(): | 48 if IsDevServer(): |
| 50 [future.wait() for future in futures] | 49 [future.wait() for future in futures] |
| OLD | NEW |