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
|
||||
for subscription in Pubsub.iterate_subscribers(cls.event):
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user