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

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

Issue 14856006: Docserver: achieve online vs offline (cron vs instance) behaviour at the object (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 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 = (None,)
8 8
9 class Future(object): 9 class Future(object):
10 '''Stores a value, error, or delegate to be used later. 10 '''Stores a value, error, or delegate to be used later.
11 ''' 11 '''
12 def __init__(self, value=_no_value, delegate=None): 12 def __init__(self, value=_no_value, delegate=None):
13 self._value = value 13 self._value = value
14 self._delegate = delegate 14 self._delegate = delegate
15 self._exc_info = None 15 self._exc_info = None
16 if (self._value is _no_value and self._delegate is None): 16 if (self._value is _no_value and self._delegate is None):
17 raise ValueError('Must have either a value or delegate.') 17 raise ValueError('Must have either a value or delegate.')
18 18
19 def Get(self): 19 def Get(self):
20 '''Gets the stored value, error, or delegate contents. 20 '''Gets the stored value, error, or delegate contents.
21 ''' 21 '''
22 if self._value is not _no_value: 22 if self._value is not _no_value:
方觉(Fang Jue) 2013/05/03 06:03:31 If you're going to use _no_value = (None,), be sur
not at google - send to devlin 2013/05/03 16:04:25 "is not" is correct because the refer to the same
cduvall 2013/05/07 23:47:03 'is not' is correct.
23 return self._value 23 return self._value
24 if self._exc_info is not None: 24 if self._exc_info is not None:
25 self._Raise() 25 self._Raise()
26 try: 26 try:
27 self._value = self._delegate.Get() 27 self._value = self._delegate.Get()
28 return self._value 28 return self._value
29 except: 29 except:
30 self._exc_info = sys.exc_info() 30 self._exc_info = sys.exc_info()
31 self._Raise() 31 self._Raise()
32 32
33 def _Raise(self): 33 def _Raise(self):
34 exc_info = self._exc_info 34 exc_info = self._exc_info
35 raise exc_info[0], exc_info[1], exc_info[2] 35 raise exc_info[0], exc_info[1], exc_info[2]
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/fake_fetchers.py ('k') | chrome/common/extensions/docs/server2/github_file_system.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698