Permalink
Browse files

cleanup

  • Loading branch information...
1 parent eb5a055 commit aeabd47a79b50a74c57f1cb9e8c5b361408ea483 @evilkost committed Apr 15, 2011
Showing with 13 additions and 3 deletions.
  1. +13 −3 brukva/client.py
View
@@ -45,6 +45,17 @@ def enable(self):
self.is_active = True
def forward_error(callbacks):
+ """
+ Syntax sugar.
+ If some error occurred inside with block,
+ it will be suppressed and forwarded to callbacks.
+
+ Error handling can be disabled using context.disable(),
+ and re enabled again using context.enable().
+
+ @type callbacks: callable or iterator over callables
+ @rtype: context
+ """
return ForwardErrorManager(callbacks)
class Message(object):
@@ -134,7 +145,7 @@ def write(self, data, try_left=None):
try:
#print('try to write: %s'% data)
self._stream.write(data)
- except IOError, e:
+ except IOError:
self.disconnect()
self.write(data, try_left - 1)
else:
@@ -322,7 +333,6 @@ def on_connect(self):
self.select(self.selected_db)
def on_disconnect(self, callbacks):
- self.pipeline().discard()
raise ConnectionError("Socket closed on remote end")
####
@@ -363,7 +373,7 @@ def call_callbacks(self, callbacks, *args, **kwargs):
@process
def execute_command(self, cmd, callbacks, *args, **kwargs):
result = None
- with forward_error(callbacks) as forward:
+ with forward_error(callbacks):
if callbacks is None:
callbacks = []
elif not hasattr(callbacks, '__iter__'):

0 comments on commit aeabd47

Please sign in to comment.