Created
May 13, 2014 18:29
-
-
Save miku/8b925b364e6619b4ae07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet import defer, reactor | |
def stopping(result): | |
print('got', result) | |
# raise RuntimeError('fail') | |
reactor.stop() | |
return result | |
def raiseException(_): | |
raise Exception() | |
def handleError(): | |
pass | |
def printIt(result): | |
print('----' * 2) | |
def done(_): | |
print('done') | |
d = defer.Deferred() | |
d.addCallback(done) | |
reactor.callLater(1, d.callback, True) | |
# return d | |
if __name__ == '__main__': | |
d = defer.Deferred() | |
# d.addCallback(raiseException) | |
d.addCallback(printIt) | |
# d.addErrback(handleError) | |
d.addBoth(stopping) | |
reactor.callLater(1, d.callback, True) | |
print('start') | |
reactor.run() | |
print('stop') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment