Browse Source

extra_cost: don't assume session is still present

Fixes #792
patch-2
Neil Booth 6 years ago
parent
commit
eb56b32987
  1. 7
      electrumx/server/session.py

7
electrumx/server/session.py

@ -488,7 +488,12 @@ class SessionManager(object):
def extra_cost(self, session):
# Add 3% of the cost of other sessions in its groups
groups = self.sessions[session]
# Note there is no guarantee that session is still in self.sessions. Example traceback:
# notify_sessions->notify->address_status->bump_cost->recalc_concurrency->extra_cost
# during which there are many places the sesssion could be removed
groups = self.sessions.get(session)
if groups is None:
return 0
groups_cost = sum(other.cost for group in groups for other in self.groups[group])
return (groups_cost - session.cost * len(groups)) * 0.03

Loading…
Cancel
Save