Permalink
Browse files

Handle disconnection

On disconnection, raise an explicit VoldemortException. That may be easier for
clients to handle recovery/reconnection rather than checking for the
struct.error raised by unpack.
  • Loading branch information...
1 parent e6abad1 commit 581d97a475e3015f8784901665d8a16a92390565 @glinmac committed May 25, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 clients/python/voldemort/client.py
@@ -239,6 +239,9 @@ def _send_request(self, connection, req_bytes):
## read a response from the connection
def _receive_response(self, connection):
size_bytes = connection.recv(4)
+ if not size_bytes:
+ raise VoldemortException('Connection closed')
+
size = struct.unpack('>i', size_bytes)[0]
bytes_read = 0
@@ -252,6 +255,7 @@ def _receive_response(self, connection):
return ''.join(data)
+
## Bootstrap cluster metadata from a list of urls of nodes in the cluster.
## The urls are tuples in the form (host, port).
## A dictionary of node_id => node is returned.

0 comments on commit 581d97a

Please sign in to comment.