Created
May 20, 2016 08:51
-
-
Save lfdversluis/855038617d767dc4b72086dae8f9b462 to your computer and use it in GitHub Desktop.
python twisted failure check problem
This file contains hidden or 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.error import ConnectingCancelledError | |
from twisted.internet.defer import Deferred, CancelledError | |
# This prints no - it doesn't work | |
d = Deferred() | |
def on_error(failure): | |
if failure.check([ConnectingCancelledError, CancelledError]): | |
print "ok" | |
else: | |
print "no" | |
print failure | |
d.addErrback(on_error) | |
d.cancel() | |
## This one does work - it prints ok | |
d = Deferred() | |
def on_error(failure): | |
if failure.check(CancelledError): | |
print "ok" | |
else: | |
print "no" | |
print failure | |
d.addErrback(on_error) | |
d.cancel() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment