Server death provokes AttributeError failure
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Python Memcached |
Fix Committed
|
Medium
|
Sean Reifschneider |
Bug Description
Version 1.48: If the server dies after the client successfully connects, further attempts to use ".set" will raise exception AttributeError: 'NoneType' object has no attribute 'sendall'.
To reproduce the problem, start memcached on localhost, and run this:
import memcache, sys
mc = memcache.
while 1:
print mc.set("a", "b")
sys.
It will print "True" and wait for input. In a second window, kill the local memcached process.
Back at the script, hit return, and the script will fail:
MemCached: MemCache: inet:localhost:
Traceback (most recent call last):
File "m.py", line 4, in <module>
print mc.set("a", "b")
File "/usr/local/
return self._set("set", key, val, time, min_compress_len)
File "/usr/local/
return _unsafe_set()
File "/usr/local/
server.
File "/usr/local/
self.
AttributeError: 'NoneType' object has no attribute 'sendall'
Here's one patch that will fix it (against 1.48):
--- /usr/local/
+++ ./memcache.py 2012-07-30 12:03:01.572273809 -0400
@@ -803,8 +803,8 @@
except _ConnectionDead
# retry once
try:
- server.
- return _unsafe_set()
+ if server.
+ return _unsafe_set()
except (_ConnectionDea
return 0
Committed to github, thanks!
https:/ /github. com/linsomniac/ python- memcached