示例#1
0
文件: rqworker.py 项目: ooda/cloudly
def work(setup_fct=None, exc_handler=None, log_level=logging.WARN):
    if setup_fct:
        setup_fct()
    listen = ['high', 'default', 'low']
    with Connection(get_redis_connection()):
        worker = Worker(map(Queue, listen))
        configure_logger(worker.log, log_level=log_level)
        if exc_handler:
            worker.push_exc_handler(exc_handler)
        log.info("Starting work.")
        worker.work()
示例#2
0
文件: tweets.py 项目: ooda/cloudly
    def __init__(self, name, tweet_processor, metadata_processor=None,
                 is_queuing=False, cache_length=100):

        self.name = name
        self.metadata_cache_key = "counts_{}".format(self.name)
        self.firehose_count_key = "firehose_count_{}".format(self.name)

        self.redis = cache.get_redis_connection()
        self.redis.delete(self.firehose_count_key)

        self.tweet_processor_fct = tweet_processor
        self.metadata_processor_fct = metadata_processor
        self.is_queuing = is_queuing
        self.previous_queue_time = None

        self.tweet_cache = []
        self.cache_length = cache_length
示例#3
0
文件: tweets.py 项目: ooda/cloudly
    def __setstate__(self, state):
        for attr, value in state.iteritems():
            setattr(self, attr, value)

        self.redis = cache.get_redis_connection()
示例#4
0
文件: rqworker.py 项目: ooda/cloudly
def get_queue():
    return Queue(connection=get_redis_connection())
示例#5
0
文件: rqworker.py 项目: ooda/cloudly
def fetch_job(job_id):
    return Job.fetch(job_id, get_redis_connection())
示例#6
0
文件: views.py 项目: hdemers/smrthome
"""
URL routes declarations.

All views are currently declared here.

"""
import os

from flask import render_template, jsonify
from twilio.rest import TwilioRestClient

from smrthome import app, make_json_error
from cloudly import logger, cache

log = logger.init(__name__)
redis = cache.get_redis_connection()


@app.errorhandler(Exception)
def error_handler(error):
    return make_json_error(error)


@app.route('/')
def index():
    """A map with real-time tweets shown.
    Configuration options are set here and available to the client via the
    global variable `appConfig`, see templates/base.html.
    """
    webapp_config = {
    }
示例#7
0
文件: pubsub.py 项目: ooda/cloudly
 def __init__(self, channel):
     super(RedisWebSocket, self).__init__(channel)
     self.websockets = []
     self.redis = cache.get_redis_connection()
     self.pubsub = self.redis.pubsub()
     self.pubsub.subscribe(self.channel)