[Twisted-web] Error output for bad deferred method signatures?
Lenny G Arbage
alengarbage at yahoo.com
Wed Nov 30 10:04:11 MST 2005
I'm curious why errors aren't reported when deferreds
are fired if the deferred method has a bad signature.
For example, if the following is run:
import httplib, sys
from twisted.web import client
from twisted.internet import reactor, threads, defer
from twisted.protocols import http
from twisted.python import failure
class getYahoo(object):
def __init__(self):
factory =
client.HTTPClientFactory("http://www.yahoo.com")
reactor.connectTCP("www.yahoo.com",80,factory)
factory.deferred.addCallback(self._gotResponse,
factory)
factory.deferred.addErrback(self._errSendReq,
factory)
self.deferred = factory.deferred
def _gotResponse(self, resp, factory):
print "yeah!"
print resp
def _errSendReq(self, err, factory):
print "shucks!"
print err
def sendRequest():
return getYahoo().deferred
if __name__ == '__main__':
def test(msg):
print msg
print respOrErr
d = sendRequest()
d.addCallback(test, "success")
d.addErrback(test, "failure")
reactor.run()
The deferred _gotResponse() and _errSendReq() fire
perfectly, but the test() function in __main__ is not
called for "success" or "failure". This is expected
as the signature is wrong -- it should be
'test(respOrErr, msg)'. What isn't clear [to me] is
why this doesn't produce an error upon firing the
deferred, but instead produces an error when the
reactor shuts down [via ctrl-c], which could be hours
later.
I have an instance of this that is more severe, where
the error output is *never* produced (maybe because of
threading?).
Is this the expected behavior, or am I doing something
atrocious to produce it?
Thanks,
Lenny
__________________________________
Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/
More information about the Twisted-web
mailing list