Skip to content

Commit 1707878

Browse files
committed
fix: portable approach to detect socket activity
Try read a byte with MSG_PEEK. This works on BSDs and Py3 under Linux. See also https://github.com/mixpanel/memcache_client/issues/4
1 parent 4a7727d commit 1707878

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

moecache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def send(self, command):
191191
if self._socket: # try to find out if the socket is still open
192192
try:
193193
self._socket.settimeout(0)
194-
self._socket.recv(0)
194+
self._socket.recv(1, socket.MSG_PEEK)
195195
# if recv didn't raise, then the socket was closed or
196196
# there is junk in the read buffer, either way, close
197197
self.close()

0 commit comments

Comments
 (0)