Skip to content

Instantly share code, notes, and snippets.

Created December 22, 2013 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/8080166 to your computer and use it in GitHub Desktop.
Save anonymous/8080166 to your computer and use it in GitHub Desktop.
Exceptions from twisted inlineCallbacks?
from twisted.internet import reactor, defer, task
@defer.inlineCallbacks
def read_input_status(address, length, callback):
print 'Before assertion.'
assert callback
print 'After assertion'
# dummy:
d = defer.Deferred()
yield d
def my_callback():
print 'Callback'
def my_errback():
print 'Errback'
d = task.deferLater(reactor, 1, read_input_status, 0x0000, 8, None)
d.addCallback(my_callback)
d.addErrback(my_errback)
reactor.callLater(5, reactor.stop)
reactor.run()
@moltob
Copy link

moltob commented Dec 22, 2013

The question here is: why is the errback not called in case of the failing assertion?

@moltob
Copy link

moltob commented Dec 22, 2013

Reason: my_callback and my_errback are lacking a required single argument to receive the result or failure of the asynchronous call respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment