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


Python Pubsub.get_subscription_count方法代码示例

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


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

示例1: on_template

# 需要导入模块: from stratum.pubsub import Pubsub [as 别名]
# 或者: from stratum.pubsub.Pubsub import get_subscription_count [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 get_subscription_count [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: on_template

# 需要导入模块: from stratum.pubsub import Pubsub [as 别名]
# 或者: from stratum.pubsub.Pubsub import get_subscription_count [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
     cls.emit(job_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, clean_jobs)
     
     cnt = Pubsub.get_subscription_count(cls.event)
     log.info("BROADCASTED to %d connections in %.03f sec" % (cnt, (Interfaces.timestamper.time() - start)))
开发者ID:Devianttwo,项目名称:Stratum-Scrypt-Jane,代码行数:17,代码来源:subscription.py

示例4: on_template

# 需要导入模块: from stratum.pubsub import Pubsub [as 别名]
# 或者: from stratum.pubsub.Pubsub import get_subscription_count [as 别名]
    def on_template(cls, is_new_block):
        '''This is called when TemplateRegistry registers
           new block which we have to broadcast clients.'''

        start = posix_time()

        clean_jobs = is_new_block
        (job_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, _) = \
                        Interfaces.template_registry.get_last_template_broadcast_args()

        if not is_new_block:
            try:
                cls.before_broadcast.callback(True)
                cls.before_broadcast = defer.Deferred()
            except:
                log.exception("before_broadcast callback failed!")

        # Push new job to subscribed clients
        cls.emit("%x"%job_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, clean_jobs)

        cnt = Pubsub.get_subscription_count(cls.event)
        log.info("BROADCASTED to %d connections in %.03f sec" % (cnt, (posix_time() - start)))
开发者ID:frrp,项目名称:bitcoin-mining-pool,代码行数:24,代码来源:subscription.py

示例5: get_num_connections

# 需要导入模块: from stratum.pubsub import Pubsub [as 别名]
# 或者: from stratum.pubsub.Pubsub import get_subscription_count [as 别名]
 def get_num_connections(cls):
     return Pubsub.get_subscription_count(cls.event)
开发者ID:digideskio,项目名称:stratum-proxy-ng,代码行数:4,代码来源:stratum_listener.py


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