diff options
author | andymccurdy <andy@andymccurdy.com> | 2010-02-16 23:04:39 -0800 |
---|---|---|
committer | andymccurdy <andy@andymccurdy.com> | 2010-02-16 23:04:39 -0800 |
commit | 5ce4a90fe42d20e180a9c28ddfa41dd09cf77aa4 (patch) | |
tree | 7b2f2c3874e33d7b21d7cbdd1861a423f669d73b /redis/client.py | |
parent | 6d3269b19a5929398c3d1b2faad6a3fb372733a5 (diff) | |
download | redis-py-5ce4a90fe42d20e180a9c28ddfa41dd09cf77aa4.tar.gz |
fixed a pipeline bug where a connection that had timed out and needed to re-auth or re-select the appropriate database would end up adding the auth/select command to the end of the pipeline rather than executing immediately.
Diffstat (limited to 'redis/client.py')
-rw-r--r-- | redis/client.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/redis/client.py b/redis/client.py index 6bbda2c..448edf6 100644 --- a/redis/client.py +++ b/redis/client.py @@ -335,7 +335,7 @@ class Redis(object): the appropriate database. """ if self.connection.password: - if not self.auth(self.connection.password): + if not self.format_inline('AUTH', self.connection.password): raise AuthenticationError("Invalid Password") self.format_inline('SELECT', self.connection.db) @@ -350,10 +350,6 @@ class Redis(object): self.connection = self.get_connection(host, port, db, password) #### SERVER INFORMATION #### - def auth(self, password): - "Authenticate with the Redis server" - return self.format_inline('AUTH', password) - def bgsave(self): """ Tell the Redis server to save its data to disk. Unlike save(), @@ -897,7 +893,15 @@ class Pipeline(Redis): At some other point, you can then run: pipe.execute(), which will execute all commands queued in the pipe. """ - self.command_stack.append((command_name, command, options)) + # if the command_name is 'AUTH' or 'SELECT', then this command + # must have originated after a socket connection and a call to + # _setup_connection(). run these commands immediately without + # buffering them. + if command_name in ('AUTH', 'SELECT'): + response = self._execute([(command_name, command, options)]) + return response[0] + else: + self.command_stack.append((command_name, command, options)) return self def _execute(self, commands): |