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)
if method in ['server.version']:
session.version = params[0]
+ def get_sessions(self):
+ with self.lock:
+ r = self.sessions[:]
+ return r
def add_session(self, session):
with self.lock:
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.
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