I'm having problems with using inlineCallbacks in the finger tutorial. 
I've used them successfully in some other test programs, but in this case
I really don't know what I'm doing wrong.

Here's the FingerProtocol code from the finger tutorial:

class FingerProtocol(basic.LineReceiver):
    def lineReceived(self, user):
        self.factory.getUser(user) \
            .addErrback(lambda _: "Internal error in server") \
            .addCallback(lambda m:
                             (self.transport.write(m + "\r\n"),
                              self.transport.loseConnection()))

And here's my modified version:

class FingerProtocol(basic.LineReceiver):
    @defer.inlineCallbacks
    def lineReceived(self, user):
        try:
            data = yield self.factory.getUser(user)
        except Exception:
            data = "Internal error in server"
        self.transport.write(data + "\r\n")
        self.transport.loseConnection()

For some reason, in my version, the connection is getting terminated
before any writes can take place.  Even if I comment out the
loseConnection line, still nothing goes across to the client and the
connection still gets terminated.

Could anyone tell me where I'm going wrong on this?  Thanks in advance.

- Paul Goins



_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web

Reply via email to