Browse Source

session.py: close sessions hitting the hard limit

patch-2
Neil Booth 6 years ago
parent
commit
4f65e3423f
  1. 4
      electrumx/server/session.py

4
electrumx/server/session.py

@ -234,11 +234,15 @@ class SessionManager(object):
session_class = self.env.coin.SESSIONCLS
while True:
await sleep(100)
async with TaskGroup() as group:
for session in sorted(self.sessions, key=lambda s: s.cost, reverse=True):
# Subs have an on-going cost so decay more slowly with more subs
session.cost_decay_per_sec = (
session_class.cost_hard_limit / (10000 + 5 * session.sub_count()))
try:
session.recalc_concurrency()
except FinalRPCError:
await group.spawn(session.close())
def _get_info(self):
'''A summary of server state.'''

Loading…
Cancel
Save