]> git.jsancho.org Git - pyrabbit.git/commitdiff
Incremental delay when receiving messages (better performance) master
authorJavier Sancho <jsf@jsancho.org>
Wed, 30 Oct 2013 14:25:15 +0000 (15:25 +0100)
committerJavier Sancho <jsf@jsancho.org>
Wed, 30 Oct 2013 14:25:15 +0000 (15:25 +0100)
pyrabbit.py

index dfb9ac8f797051d6ad373962a89390c1ab85f48b..351e98d6d39994afe7ce3271ae8a952b901740f7 100644 (file)
@@ -57,8 +57,11 @@ class Connection(object):
         t_start = time.time()
         method = None
         i = 0
+        delay = 0.0
         while method is None and (time.time()-t_start < timeout or timeout <= 0):
-            time.sleep(0.1)
+            time.sleep(delay)
+            if delay < 1:
+                delay += 0.01
             method, properties, body = self.channel.basic_get(queues[i])
             if i == len(queues) - 1:
                 i = 0