argh, ugly hack for problem of stale requests poisoning queues

This commit is contained in:
Seth Schoen
2012-08-08 13:41:15 -07:00
parent cb2040a3ac
commit c4c8bd04f9
+10
View File
@@ -290,6 +290,16 @@ for message in ps.listen():
populated_queue = message["data"]
if populated_queue in dispatch:
queue, function = dispatch[populated_queue]
for repetition in (1,2):
# This is a potentially inappropriate hack to prevent backlogs
# from accumulating in queues if daemons die or if spurious
# requests arrived while no daemons were listening. The idea
# is that every daemon process double-checks a queue that it
# was told to look at, processing it twice per pubsub message
# instead of once. This causes a pressure on the daemon to
# empty the queue over time even if it isn't explicitly asked
# to. For example, if asked 7 times to process a particular
# queue, a daemon instance would try 14 times.
session = r.rpop(queue)
if session:
if debug: print "going to %s for %s" % (populated_queue, session)