X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=processor.py;h=ec62d482686544e77a00d196048fb9c174f20125;hb=a40eecde0cf53045098c0db158f96274d3429273;hp=71b9d625ebbfe61dfe1d4704042b602976e4a2e3;hpb=ac6403ee0964644e1afe3f5df2daaf668a0ef261;p=electrum-server.git diff --git a/processor.py b/processor.py index 71b9d62..ec62d48 100644 --- a/processor.py +++ b/processor.py @@ -83,6 +83,7 @@ class RequestDispatcher(threading.Thread): self.internal_ids = {} self.internal_id = 1 self.lock = threading.Lock() + self.idlock = threading.Lock() self.sessions = [] self.processors = {} @@ -104,11 +105,11 @@ class RequestDispatcher(threading.Thread): return x def get_session_id(self, internal_id): - with self.lock: + with self.idlock: return self.internal_ids.pop(internal_id) def store_session_id(self, session, msgid): - with self.lock: + with self.idlock: self.internal_ids[self.internal_id] = session, msgid r = self.internal_id self.internal_id += 1 @@ -137,7 +138,6 @@ class RequestDispatcher(threading.Thread): suffix = method.split('.')[-1] if session is not None: - is_new = session.protocol_version >= 0.5 if suffix == 'subscribe': session.subscribe_to_service(method, params) @@ -160,9 +160,6 @@ class RequestDispatcher(threading.Thread): except: pass - #if session.protocol_version < 0.6: - # print_log("stopping session from old client", session.protocol_version) - # session.stop() def get_sessions(self): with self.lock: @@ -180,8 +177,9 @@ class RequestDispatcher(threading.Thread): sessions = self.sessions[:] active_sessions = [] + now = time.time() for session in sessions: - if not session.stopped(): + if not session.stopped() and (now - session.time) < 1000: # If session is still alive then re-add it back # to our internal register active_sessions.append(session)