Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Side by Side Diff: chrome/common/extensions/docs/server2/future.py

Issue 151773002: Docserver: Properly implement the Cron logic for ContentProvider and TemplateDataSource so that the… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: yoz + rebase Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 import sys 5 import sys
6 6
7 _no_value = object() 7 _no_value = object()
8 8
9 9
10 def Collect(futures):
11 '''Creates a Future which returns a list of results from each Future in
12 |future|.
Yoyo Zhou 2014/02/04 21:42:13 futures
not at google - send to devlin 2014/02/04 21:57:13 Done.
13 '''
14 return Future(delegate=Gettable(lambda: [f.Get() for f in futures]))
15
16
10 class Gettable(object): 17 class Gettable(object):
11 '''Allows a Future to accept a callable as a delegate. Wraps |f| in a .Get 18 '''Allows a Future to accept a callable as a delegate. Wraps |f| in a .Get
12 interface required by Future. 19 interface required by Future.
13 ''' 20 '''
14 def __init__(self, f, *args): 21 def __init__(self, f, *args):
15 self._g = lambda: f(*args) 22 self._g = lambda: f(*args)
16 def Get(self): 23 def Get(self):
17 return self._g() 24 return self._g()
18 25
19 26
(...skipping 19 matching lines...) Expand all
39 try: 46 try:
40 self._value = self._delegate.Get() 47 self._value = self._delegate.Get()
41 return self._value 48 return self._value
42 except: 49 except:
43 self._exc_info = sys.exc_info() 50 self._exc_info = sys.exc_info()
44 self._Raise() 51 self._Raise()
45 52
46 def _Raise(self): 53 def _Raise(self):
47 exc_info = self._exc_info 54 exc_info = self._exc_info
48 raise exc_info[0], exc_info[1], exc_info[2] 55 raise exc_info[0], exc_info[1], exc_info[2]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698