- commit
- aad2aa7237e4d310c25f7bf8581ad0202e05e2b3
- parent
- 8520910c981ce22174305168561680365230691b
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2014-10-04 15:59
allow deferreds to fail silently on multiple resolves/rejects
Diffstat
| M | laneya/deferred.py | 8 | ++++---- |
1 files changed, 4 insertions, 4 deletions
diff --git a/laneya/deferred.py b/laneya/deferred.py
@@ -30,7 +30,7 @@ class Deferred(object): 30 30 def __init__(self): 31 31 self.promise = Promise() 32 3233 -1 def resolve(self, value, status=RESOLVED):-1 33 def resolve(self, value, silent=False, status=RESOLVED): 34 34 """Resolve the deferred. 35 35 36 36 All success callbacks that are registered on the promise will be @@ -50,17 +50,17 @@ class Deferred(object): 50 50 callback(value).then(d.resolve, d.reject) 51 51 else: # rejected 52 52 errback(value).then(d.resolve, d.reject)53 -1 else:-1 53 elif not silent: 54 54 raise AlreadyDoneError 55 5556 -1 def reject(self, value):-1 56 def reject(self, value, silent=False): 57 57 """Reject the deferred. 58 58 59 59 Works execatly like :py:meth:`resolve`, only that it triggers the 60 60 execution of error callbacks. 61 61 62 62 """63 -1 return self.resolve(value, status=REJECTED)-1 63 return self.resolve(value, silent=silent, status=REJECTED) 64 64 65 65 66 66 class Promise(object):