def iter_messages_pubsub(channels, prefix="channel", timeout=1): pub = db.pubsub() if channels: pub.subscribe(["%s:%s" (prefix, channel) for channel in channels]) else: pub.psubscribe(["%s:*" % (prefix)]) while True: yield get_message_pubsub(pub, timeout=timeout)
def iter_status(): pub = db.pubsub() pub.subscribe(["queues:status"]) yield get_status() while True: channel = get_message_pubsub(pub) if channel is not None: yield get_status(channel) else: yield