server.expect("END") needs to be in a finally block

Bug #713451 reported by Jay Farrimond
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Python Memcached
Fix Released
Undecided
Sean Reifschneider

Bug Description

In the _get() function, the server.expect("END") statement needs to be in a finally block, so that it gets executed no matter what. When the _recv_value() function throws an exception, then "END" remains in the socket's buffer, which causes the next _get() command to return (None,None), then the call after that to return the previous call's data.

In my specific case, _recv_value() was occasionally throwing exceptions from decompress() when it got bad data to decompress, which is what was causing this. The fact that the data to decompress was bad is my own fault, but this could happen to others and is very easy to fix.

Revision history for this message
Jay Farrimond (jay-farrimond) wrote :

Here's the code I implemented to fix this:

try:
    value = self._recv_value(server, flags, rlen)
finally:
    server.expect("END")

Revision history for this message
Sean Reifschneider (jafo) wrote :

Committed as r49. Thanks for the fix!

Changed in python-memcached:
assignee: nobody → Sean Reifschneider (jafo)
status: New → Fix Committed
Changed in python-memcached:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.