diff options
author | Dan Colish <dcolish@gmail.com> | 2011-03-14 17:56:17 -0400 |
---|---|---|
committer | Dan Colish <dcolish@gmail.com> | 2011-03-14 17:56:17 -0400 |
commit | aefa71df8f47a70c772cf7721f881bfd74d9cf2a (patch) | |
tree | c1c3c457d8ad29ded5835f35a8656f884d791e72 /redis/client.py | |
parent | 6796d6bc9c7b7be904c31bc07b210e46f0a90652 (diff) | |
download | redis-py-aefa71df8f47a70c772cf7721f881bfd74d9cf2a.tar.gz |
add PubSubError to better report disallowed command when using pub/sub
Diffstat (limited to 'redis/client.py')
-rw-r--r-- | redis/client.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/redis/client.py b/redis/client.py index 7b1c1ae..57ea0f0 100644 --- a/redis/client.py +++ b/redis/client.py @@ -8,6 +8,7 @@ from redis.exceptions import ( AuthenticationError, ConnectionError, DataError, + PubSubError, RedisError, ResponseError, WatchError, @@ -229,8 +230,8 @@ class Redis(threading.local): def _execute_command(self, command_name, command, **options): subscription_command = command_name in self.SUBSCRIPTION_COMMANDS if self.subscribed and not subscription_command: - raise RedisError("Cannot issue commands other than SUBSCRIBE and " - "UNSUBSCRIBE while channels are open") + raise PubSubError("Cannot issue commands other than SUBSCRIBE and " + "UNSUBSCRIBE while channels are open") try: self.connection.send(command, self) if subscription_command: @@ -319,7 +320,7 @@ class Redis(threading.local): def shutdown(self): "Shutdown the server" if self.subscribed: - raise RedisError("Can't call 'shutdown' from a pipeline'") + raise PubSubError("Can't call 'shutdown' when 'subscribed'") try: self.execute_command('SHUTDOWN') except ConnectionError: @@ -610,7 +611,7 @@ class Redis(threading.local): Watches the values at keys ``names``, or None if the key doesn't exist """ if self.subscribed: - raise RedisError("Can't call 'watch' from a pipeline'") + raise PubSubError("Can't call 'watch' when 'subscribed'") return self.execute_command('WATCH', *names) @@ -619,7 +620,7 @@ class Redis(threading.local): Unwatches the value at key ``name``, or None of the key doesn't exist """ if self.subscribed: - raise RedisError("Can't call 'unwatch' from a pipeline'") + raise PubSubError("Can't call 'unwatch' when 'subscribed'") return self.execute_command('UNWATCH') |