changeset 34:39295953624f

Redis requires and integer for a timeout (no floats)
author btimby
date Tue, 15 May 2012 20:58:27 +0000 (2012-05-15)
parents 22831bdce9fd
children 9805eefcb58c
files queues/backends/redisd.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/queues/backends/redisd.py	Mon May 14 19:22:57 2012 +0000
+++ b/queues/backends/redisd.py	Tue May 15 20:58:27 2012 +0000
@@ -7,6 +7,7 @@
 from queues.backends.base import BaseQueue
 from queues import InvalidBackend, QueueException
 import os
+import math
 
 try:
     import redis
@@ -67,7 +68,9 @@
     def read(self, block=False, timeout=0):
         try:
             if block:
-                m = self._connection.blpop(self.name, timeout=timeout)
+                # Redis requires an integer, so round a float UP to the nearest
+                # int (0.1 -> 1).
+                m = self._connection.blpop(self.name, timeout=int(math.ceil(timeout)))
             else:
                 m = self._connection.lpop(self.name)
             if m is None: