THRIFT-148. py: One more time, reapply the most *recent* patch

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@749795 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Kevin Clark 2009-03-03 22:13:46 +00:00
parent e43f7e0925
commit e8d3c47944

View File

@ -1,6 +1,7 @@
from zope.interface import implements, Interface, Attribute from zope.interface import implements, Interface, Attribute
from twisted.internet.protocol import Protocol, ServerFactory, ClientFactory, from twisted.internet.protocol import Protocol, ServerFactory, ClientFactory, \
connectionDone connectionDone
from twisted.internet import defer
from twisted.protocols import basic from twisted.protocols import basic
from twisted.python import log from twisted.python import log
from thrift.transport import TTransport from thrift.transport import TTransport
@ -45,6 +46,7 @@ class ThriftClientProtocol(basic.Int32StringReceiver):
self._oprot_factory = oprot_factory self._oprot_factory = oprot_factory
self.recv_map = {} self.recv_map = {}
self.started = defer.Deferred()
def dispatch(self, msg): def dispatch(self, msg):
self.sendString(msg) self.sendString(msg)
@ -52,6 +54,7 @@ class ThriftClientProtocol(basic.Int32StringReceiver):
def connectionMade(self): def connectionMade(self):
tmo = TCallbackTransport(self.dispatch) tmo = TCallbackTransport(self.dispatch)
self.client = self._client_class(tmo, self._oprot_factory) self.client = self._client_class(tmo, self._oprot_factory)
self.started.callback(self.client)
def connectionLost(self, reason=connectionDone): def connectionLost(self, reason=connectionDone):
for k,v in self.client._reqs.iteritems(): for k,v in self.client._reqs.iteritems():