Exemplo n.º 1
0
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()
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    def __setstate__(self, state):
        for attr, value in state.iteritems():
            setattr(self, attr, value)

        self.redis = cache.get_redis_connection()
Exemplo n.º 4
0
def get_queue():
    return Queue(connection=get_redis_connection())
Exemplo n.º 5
0
def fetch_job(job_id):
    return Job.fetch(job_id, get_redis_connection())
Exemplo n.º 6
0
"""
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 = {
    }
Exemplo n.º 7
0
 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)