当前位置: 首页>>代码示例>>Python>>正文


Python Pubsub.iterate_subscribers方法代码示例

本文整理汇总了Python中stratum.pubsub.Pubsub.iterate_subscribers方法的典型用法代码示例。如果您正苦于以下问题:Python Pubsub.iterate_subscribers方法的具体用法?Python Pubsub.iterate_subscribers怎么用?Python Pubsub.iterate_subscribers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stratum.pubsub.Pubsub的用法示例。


在下文中一共展示了Pubsub.iterate_subscribers方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_template

# 需要导入模块: from stratum.pubsub import Pubsub [as 别名]
# 或者: from stratum.pubsub.Pubsub import iterate_subscribers [as 别名]
    def on_template(cls, is_new_block):
        """This is called when TemplateRegistry registers
           new block which we have to broadcast clients."""
        
        start = Interfaces.timestamper.time()
        clean_jobs = is_new_block
        
        (job_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, _) = \
            Interfaces.template_registry.get_last_broadcast_args()

        # Push new job to subscribed clients
        for subscription in Pubsub.iterate_subscribers(cls.event):
            try:
                if subscription != None:
                    session = subscription.connection_ref().get_session()
                    session.setdefault('authorized', {})
                    if session['authorized'].keys():
                        worker_name = session['authorized'].keys()[0]
                        difficulty = session['difficulty']
                        work_id = Interfaces.worker_manager.register_work(worker_name, job_id, difficulty)
                        #log.debug("emitting for work id %s job id %s block %s " % (work_id, job_id, prevhash))
                        subscription.emit_single(work_id, prevhash, coinb1, coinb2, merkle_branch, version,
                                                 nbits, ntime, clean_jobs)
                    else:
                        subscription.emit_single(job_id, prevhash, coinb1, coinb2, merkle_branch, version,
                                                 nbits, ntime, clean_jobs)
            except Exception as e:
                log.exception("Error broadcasting work to client %s" % str(e))
                pass
        
        cnt = Pubsub.get_subscription_count(cls.event)
        log.info("BROADCASTED to %d connections in %.03f sec" % (cnt, (Interfaces.timestamper.time() - start)))
开发者ID:penner42,项目名称:stratum-mining,代码行数:34,代码来源:subscription.py

示例2: print_subs

# 需要导入模块: from stratum.pubsub import Pubsub [as 别名]
# 或者: from stratum.pubsub.Pubsub import iterate_subscribers [as 别名]
 def print_subs(cls):
     c = Pubsub.get_subscription_count(cls.event)
     log.info(c)
     for subs in Pubsub.iterate_subscribers(cls.event):
         s = Pubsub.get_subscription(
             subs.connection_ref(),
             cls.event,
             key=None)
         log.info(s)
开发者ID:digideskio,项目名称:stratum-proxy-ng,代码行数:11,代码来源:stratum_listener.py

示例3: get_server_stats

# 需要导入模块: from stratum.pubsub import Pubsub [as 别名]
# 或者: from stratum.pubsub.Pubsub import iterate_subscribers [as 别名]
    def get_server_stats(self):
        serialized = '' 
        for subscription in Pubsub.iterate_subscribers(self.event):
            try:
                if subscription != None:
                    session = subscription.connection_ref().get_session()
                    session.setdefault('authorized', {})
                    if session['authorized'].keys():
                        worker_name = session['authorized'].keys()[0]
                        difficulty = session['difficulty']
                        ip = subscription.connection_ref()._get_ip()
                        serialized += json.dumps({'worker_name': worker_name, 'ip': ip, 'difficulty': difficulty})
                    else:
                        pass
            except Exception as e:
                log.exception("Error getting subscriptions %s" % str(e))
                pass

        log.debug("Server stats request: %s" % serialized)
        return '%s' % serialized
开发者ID:McKenzy83,项目名称:merged-stratum,代码行数:22,代码来源:service.py

示例4: get_server_stats

# 需要导入模块: from stratum.pubsub import Pubsub [as 别名]
# 或者: from stratum.pubsub.Pubsub import iterate_subscribers [as 别名]
    def get_server_stats(self):
        serialized = ""
        for subscription in Pubsub.iterate_subscribers(self.event):
            try:
                if subscription != None:
                    session = subscription.connection_ref().get_session()
                    session.setdefault("authorized", {})
                    if session["authorized"].keys():
                        worker_name = session["authorized"].keys()[0]
                        difficulty = session["difficulty"]
                        ip = subscription.connection_ref()._get_ip()
                        serialized += json.dumps({"worker_name": worker_name, "ip": ip, "difficulty": difficulty})
                    else:
                        pass
            except Exception as e:
                log.exception("Error getting subscriptions %s" % str(e))
                pass

        log.debug("Server stats request: %s" % serialized)
        return "%s" % serialized
开发者ID:hevoc123,项目名称:stratum-mining,代码行数:22,代码来源:service.py

示例5: disconnect_all

# 需要导入模块: from stratum.pubsub import Pubsub [as 别名]
# 或者: from stratum.pubsub.Pubsub import iterate_subscribers [as 别名]
 def disconnect_all(cls):
     for subs in Pubsub.iterate_subscribers(cls.event):
         subs.connection_ref().transport.loseConnection()
开发者ID:yawkat,项目名称:stratum-mining-proxy,代码行数:5,代码来源:stratum_listener.py

示例6: reconnect_all

# 需要导入模块: from stratum.pubsub import Pubsub [as 别名]
# 或者: from stratum.pubsub.Pubsub import iterate_subscribers [as 别名]
 def reconnect_all(cls):
     for subs in Pubsub.iterate_subscribers(cls.event):
         if subs.connection_ref().transport is not None:
             subs.connection_ref().transport.loseConnection()
开发者ID:digideskio,项目名称:stratum-proxy-ng,代码行数:6,代码来源:stratum_listener.py


注:本文中的stratum.pubsub.Pubsub.iterate_subscribers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。