Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions memcached/python_modules/memcached.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import time
import socket
import select
import errno

descriptors = list()
Desc_Skel = {}
Expand Down Expand Up @@ -78,18 +79,27 @@ def update_metric(self):
sock.send("stats\r\n")

while True:
rfd, wfd, xfd = select.select([sock], [], [], self.timeout)
if not rfd:
print >>sys.stderr, "ERROR: select timeout"
break

for fd in rfd:
if fd == sock:
data = fd.recv(8192)
msg += data

if msg.find("END"):
break
try:
rfd, wfd, xfd = select.select([sock], [], [], self.timeout)

if not rfd:
print >>sys.stderr, "ERROR: select timeout"
break

for fd in rfd:
if fd == sock:
try:
data = fd.recv(8192)
msg += data
except (IOError, OSError), e:
if e.errno != errno.EINTR:
raise

if msg.find("END"):
break
except select.error, e:
if e[0] != errno.EINTR:
raise

sock.close()
except socket.error, e:
Expand Down