This:
d.addCallback(self.Success(request))
is the same as:
temp = self.Success(request)
d.addCallback(temp)
which, given the definition of Success
is the same as:
request.write('Success')
request.finish()
temp = None
d.addCallback(None)
This probably fails with Request.write called on a request after Request.finish was called. because d.addCallback(None)
raises an exception and the server tries to report the error as the response. However, since finish
has already been called it can't write the error.
The correct way to add a callback to a Deferred
with an extra argument is d.addCallback(self.Success, request)
. Callbacks on a Deferred
always get passed the result of the Deferred
as the first argument, though - so the correct signature for Success
is:
def Success(self, result, request):
...