Skip to content
Browse files

Manual merge of exception handling from testrunner/mcsoda.py

  • Loading branch information...
1 parent 73bfe72 commit 72268eb47fe6e4a04e10965a034e2e51b16c03b4 @steveyen steveyen committed Feb 17, 2012
Showing with 43 additions and 24 deletions.
  1. +43 −24 mcsoda.py
View
67 mcsoda.py
@@ -15,8 +15,9 @@
sys.path.append(".")
try:
- import logger
- log = logger.new_logger("mcsoda")
+ import logging
+ logging.config.fileConfig("mcsoda.logging.conf")
+ log = logging.getLogger()
except:
class P:
def error(self, m): print(m)
@@ -653,37 +654,50 @@ def inflight_complete(self, inflight_grp):
def inflight_send(self, inflight_msg):
sent = 0
for server, buf in inflight_msg:
- conn = self.awareness.memcacheds[server]
- conn.s.send(buf)
- sent += len(buf)
+ try:
+ conn = self.awareness.memcacheds[server]
+ conn.s.send(buf)
+ sent += len(buf)
+ except:
+ pass
return sent
def inflight_recv(self, inflight, inflight_grp, expectBuffer=None):
received = 0
s_cmds = inflight_grp['s_cmds']
reset_my_awareness = False
backoff = False
+
for server in s_cmds.keys():
- conn = self.awareness.memcacheds[server]
try:
- recvBuf = conn.recvBuf
+ conn = self.awareness.memcacheds[server]
+ try:
+ recvBuf = conn.recvBuf
+ except:
+ recvBuf = ''
+ if expectBuffer == False and recvBuf != '':
+ raise Exception("Was expecting empty buffer, but have (" + \
+ str(len(recvBuf)) + "): " + recvBuf)
+ cmds = s_cmds[server]
+ for i in range(cmds):
+ try:
+ rcmd, keylen, extralen, errcode, datalen, ropaque, val, recvBuf = \
+ self.recvMsgSockBuf(conn.s, recvBuf)
+ received += datalen + MIN_RECV_PACKET
+ if errcode == ERR_NOT_MY_VBUCKET:
+ reset_my_awareness = True
+ elif errcode == ERR_ENOMEM or \
+ errcode == ERR_EBUSY or \
+ errcode == ERR_ETMPFAIL:
+ backoff = True
+ except:
+ reset_my_awareness = True
+ backoff = True
+ conn.recvBuf = recvBuf
except:
- recvBuf = ''
- if expectBuffer == False and recvBuf != '':
- raise Exception("Was expecting empty buffer, but have (" + \
- str(len(recvBuf)) + "): " + recvBuf)
- cmds = s_cmds[server]
- for i in range(cmds):
- rcmd, keylen, extralen, errcode, datalen, ropaque, val, recvBuf = \
- self.recvMsgSockBuf(conn.s, recvBuf)
- received += datalen + MIN_RECV_PACKET
- if errcode == ERR_NOT_MY_VBUCKET:
- reset_my_awareness = True
- elif errcode == ERR_ENOMEM or \
- errcode == ERR_EBUSY or \
- errcode == ERR_ETMPFAIL:
- backoff = True
- conn.recvBuf = recvBuf
+ reset_my_awareness = True
+ backoff = True
+
if backoff:
self.backoff = max(self.backoff, 0.1) * \
self.cfg.get('backoff-factor', 2.0)
@@ -692,8 +706,13 @@ def inflight_recv(self, inflight, inflight_grp, expectBuffer=None):
time.sleep(self.backoff)
else:
self.backoff = 0
+
if reset_my_awareness:
- self.awareness.reset()
+ try:
+ self.awareness.reset()
+ except:
+ pass
+
return received
def recvMsgSockBuf(self, sock, buf):

0 comments on commit 72268eb

Please sign in to comment.
Something went wrong with that request. Please try again.