| OLD | NEW |
| 1 # Copyright 2016 The LUCI Authors. All rights reserved. | 1 # Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed by the Apache v2.0 license that can be | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Utilities for GCE Backend.""" | 5 """Utilities for GCE Backend.""" |
| 6 | 6 |
| 7 import hashlib | 7 import hashlib |
| 8 import json | 8 import json |
| 9 | 9 |
| 10 from google.appengine.ext import ndb | 10 from google.appengine.ext import ndb |
| 11 | 11 |
| 12 | 12 |
| 13 def batch_process_async(items, f, max_concurrent=50): | 13 def batch_process_async(items, f, max_concurrent=50): |
| (...skipping 12 matching lines...) Expand all Loading... |
| 26 items = items[max_concurrent - num_futures:] | 26 items = items[max_concurrent - num_futures:] |
| 27 ndb.Future.wait_any(futures) | 27 ndb.Future.wait_any(futures) |
| 28 futures = [future for future in futures if not future.done()] | 28 futures = [future for future in futures if not future.done()] |
| 29 if futures: | 29 if futures: |
| 30 ndb.Future.wait_all(futures) | 30 ndb.Future.wait_all(futures) |
| 31 | 31 |
| 32 | 32 |
| 33 def compute_checksum(json_encodable): | 33 def compute_checksum(json_encodable): |
| 34 """Computes a checksum from a JSON-encodable dict or list.""" | 34 """Computes a checksum from a JSON-encodable dict or list.""" |
| 35 return hashlib.sha1(json.dumps(json_encodable, sort_keys=True)).hexdigest() | 35 return hashlib.sha1(json.dumps(json_encodable, sort_keys=True)).hexdigest() |
| OLD | NEW |