Mercurial > public > queues
changeset 33:22831bdce9fd
Added timeouts for blocking mode
author | btimby |
---|---|
date | Mon, 14 May 2012 19:22:57 +0000 (2012-05-14) |
parents | c70414fbc552 |
children | 39295953624f |
files | queues/backends/dummy.py queues/backends/redisd.py |
diffstat | 2 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/queues/backends/dummy.py Thu Apr 26 14:49:46 2012 +0000 +++ b/queues/backends/dummy.py Mon May 14 19:22:57 2012 +0000 @@ -20,9 +20,9 @@ self.backend = 'dummy' self.name = name - def read(self, block=False): + def read(self, block=False, timeout=None): try: - message = self.queue.get(block=block) + message = self.queue.get(block=block, timeout=timeout) self.queue.task_done() return message except queue.Empty, e:
--- a/queues/backends/redisd.py Thu Apr 26 14:49:46 2012 +0000 +++ b/queues/backends/redisd.py Mon May 14 19:22:57 2012 +0000 @@ -64,10 +64,10 @@ except redis.RedisError, e: raise QueueException, "%s" % e - def read(self, block=False): + def read(self, block=False, timeout=0): try: if block: - m = self._connection.blpop(self.name) + m = self._connection.blpop(self.name, timeout=timeout) else: m = self._connection.lpop(self.name) if m is None: