Hi, We have been using the python thrift lib and I noticed some strange behaviour: -
If i call: - transport = TTransport.TBufferedTransport(self.socket) transport.open() transport.isOpen() The isOpen() will return true, even if the connection failed. I have traced the problem down to class TSocket. The isOpen method works like this:- def isOpen(self): return self.handle is not None But if open fails it will not set self.handle back to None: - def open(self): try: res0 = self._resolveAddr() for res in res0: self.handle = socket.socket(res[0], res[1]) self.handle.settimeout(self._timeout) try: self.handle.connect(res[4]) except socket.error, e: if res is not res0[-1]: continue else: raise e break except socket.error, e: if self._unix_socket: message = 'Could not connect to socket %s' % self._unix_socket else: message = 'Could not connect to %s:%s' % (self.host, self.port) raise TTransportException(type=TTransportException.NOT_OPEN, message=message) Setting self.handle to None when the connection fails fixes my issue: - def open(self): try: res0 = self._resolveAddr() for res in res0: self.handle = socket.socket(res[0], res[1]) self.handle.settimeout(self._timeout) try: self.handle.connect(res[4]) except socket.error, e: if res is not res0[-1]: continue else: self.handle = None raise e break except socket.error, e: if self._unix_socket: message = 'Could not connect to socket %s' % self._unix_socket else: message = 'Could not connect to %s:%s' % (self.host, self.port) raise TTransportException(type=TTransportException.NOT_OPEN, message=message) Is this the correct way to fix the issue? Should i raise a jira ticket or submit a patch or something? Thanks, Steve -- *Stephen Briney* •**** *Software Engineer* *Xyratex***** *office:***** *+44 (0)2392 496542* *www.xyratex.com* <http://www.xyratex.com/> *Connect with Xyratex<http://blog.xyratex.com/> * -- ------------------------------ For additional information including the registered office and the treatment of Xyratex confidential information please visit www.xyratex.com ------------------------------