server.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:redis-pubsub 作者: xitongjiagoushi 项目源码 文件源码
def __init__(self):
        # register tornado's RequestHandler to designated context path
        handlers = [
            (r'/publish', PublishHandler),
            (r'/subscribe', SubscribeHandler), 
            (r'/', IndexHandler),
            ]
        settings = dict(
            template_path=path.join(path.dirname(__file__), 'templates'),
            static_path=path.join(path.dirname(__file__), 'static'),
        )
        super(Application, self).__init__(handlers, **settings)
        # redis singeleton to share among handlers
        self.redis = redis.StrictRedis(host=options.redis_host, port=options.redis_port, db=options.redis_db, password=options.redis_password)
        # redis pubsub singeleton to share among handler(pubsub is used to subscribe channels)
        self.pubsub = self.redis.pubsub(ignore_subscribe_messages=True)
        self.pubsub.subscribe(options.redis_channel)
        # logger to record log
        self.logger = logger


# base handler
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号