comparison mercurial/keepalive.py @ 14958:fd246aefedd3

keepalive: use safehasattr instead of hasattr
author Augie Fackler <durin42@gmail.com>
date Mon, 25 Jul 2011 20:36:59 -0500
parents a7d5816087a9
children 7de7630053cb
comparison
equal deleted inserted replaced
14957:16e5271b216f 14958:fd246aefedd3
545 # ignore the error... the caller will know if they can retry. 545 # ignore the error... the caller will know if they can retry.
546 if self.debuglevel > 0: 546 if self.debuglevel > 0:
547 print "send:", repr(str) 547 print "send:", repr(str)
548 try: 548 try:
549 blocksize = 8192 549 blocksize = 8192
550 if hasattr(str,'read') : 550 read = getattr(str, 'read', None)
551 if read is not None:
551 if self.debuglevel > 0: 552 if self.debuglevel > 0:
552 print "sendIng a read()able" 553 print "sendIng a read()able"
553 data = str.read(blocksize) 554 data = read(blocksize)
554 while data: 555 while data:
555 self.sock.sendall(data) 556 self.sock.sendall(data)
556 data = str.read(blocksize) 557 data = read(blocksize)
557 else: 558 else:
558 self.sock.sendall(str) 559 self.sock.sendall(str)
559 except socket.error, v: 560 except socket.error, v:
560 reraise = True 561 reraise = True
561 if v[0] == errno.EPIPE: # Broken pipe 562 if v[0] == errno.EPIPE: # Broken pipe