X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=processor.py;h=20fdbfd7e26b914c1be6a7157195a46cabe0a11f;hb=3051f46df11fc6c9ebe321c9ef6d726e65310129;hp=d012f5d706c972832e7874e9695a090cf81220f4;hpb=6e292a968278287f1ec190fd6bf09ee2ac8fd0b2;p=electrum-server.git diff --git a/processor.py b/processor.py index d012f5d..20fdbfd 100644 --- a/processor.py +++ b/processor.py @@ -89,6 +89,11 @@ class RequestDispatcher(threading.Thread): def pop_request(self): return self.request_queue.get() + def get_session_by_address(self, address): + for x in self.sessions: + if x.address == address: + return x + def get_session_id(self, internal_id): with self.lock: return self.internal_ids.pop(internal_id) @@ -164,6 +169,8 @@ class Session: self.subscriptions = [] self.address = '' self.name = '' + self.version = 'unknown' + self.time = time.time() threading.Timer(2, self.info).start() # Debugging method. Doesn't need to be threadsafe. @@ -176,8 +183,10 @@ class Session: break else: addr = None - print timestr(), self.name, self.address, addr,\ - len(self.subscriptions), self.version + + if self.subscriptions: + print timestr(), self.name, self.address, addr,\ + len(self.subscriptions), self.version def stopped(self): with self.lock: @@ -245,6 +254,9 @@ class ResponseDispatcher(threading.Thread): def send_response(self, internal_id, response): session, message_id = self.processor.get_session_id(internal_id) - response['id'] = message_id - session.send_response(response) + if session: + response['id'] = message_id + session.send_response(response) + else: + print "send_response: no session", message_id, internal_id, response