本文整理汇总了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)))
示例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)
示例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)))
示例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)))
示例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)