Skip to content

Commit

Permalink
Significant usability bugfixes in Python interface
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmaslanka committed Jan 31, 2012
1 parent 62e3a05 commit 5876970
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions interfaces/vanad.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def scan_frame(frame):

return resultcode, data


class VanadConnection(object):
"""
Class that represents a connection to a Vanad database
Expand Down Expand Up @@ -152,14 +151,13 @@ def __transact(self, to_send):
started_on = time()
received_data = bytearray()
while True:
rxs, txs, exs = select((self.socket, ), (self.socket, ), (), self.txrx_timeout)
rxs, txs, exs = select((self.socket, ), (), (), self.txrx_timeout)
if len(rxs) == 0: raise Exception # Timeout
# Entire op timeout exceeded
if time() - started_on > self.eo_timeout: raise Exception
if len(rxs) == 1: # Socket ready or disconnected
data = self.socket.recv(1024)
if len(data) == 0: # Socket disconnected
raise Exception
if len(data) == 0: raise Exception # Socket disconnected

received_data += data

Expand All @@ -169,6 +167,7 @@ def __transact(self, to_send):
continue
else: # Frame completed
break
self.last_activity = time() # Note the activity
if result == 0x01: return None # Not found for GET's
if len(value) == 0: return None # None and empty string have same meaning
return value
Expand Down

0 comments on commit 5876970

Please sign in to comment.