fix error when subscription is none add try catch
This commit is contained in:
parent
e2b06d2839
commit
a107473d9c
@ -24,15 +24,20 @@ class MiningSubscription(Subscription):
|
|||||||
|
|
||||||
# Push new job to subscribed clients
|
# Push new job to subscribed clients
|
||||||
for subscription in Pubsub.iterate_subscribers(cls.event):
|
for subscription in Pubsub.iterate_subscribers(cls.event):
|
||||||
session = subscription.connection_ref().get_session()
|
try:
|
||||||
session.setdefault('authorized', {})
|
if subscription != None:
|
||||||
if session['authorized'].keys():
|
session = subscription.connection_ref().get_session()
|
||||||
worker_name = session['authorized'].keys()[0]
|
session.setdefault('authorized', {})
|
||||||
difficulty = session['difficulty']
|
if session['authorized'].keys():
|
||||||
work_id = Interfaces.worker_manager.register_work(worker_name, job_id, difficulty)
|
worker_name = session['authorized'].keys()[0]
|
||||||
subscription.emit_single(work_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, clean_jobs)
|
difficulty = session['difficulty']
|
||||||
else:
|
work_id = Interfaces.worker_manager.register_work(worker_name, job_id, difficulty)
|
||||||
subscription.emit_single(job_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, clean_jobs)
|
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)
|
cnt = Pubsub.get_subscription_count(cls.event)
|
||||||
log.info("BROADCASTED to %d connections in %.03f sec" % (cnt, (Interfaces.timestamper.time() - start)))
|
log.info("BROADCASTED to %d connections in %.03f sec" % (cnt, (Interfaces.timestamper.time() - start)))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user