threadsafe get_session
authorThomasV <thomasv@gitorious>
Wed, 13 Jun 2012 11:45:10 +0000 (15:45 +0400)
committerThomasV <thomasv@gitorious>
Wed, 13 Jun 2012 11:45:10 +0000 (15:45 +0400)
backends/irc/__init__.py
processor.py

index 3b698d8..200d19f 100644 (file)
@@ -120,7 +120,7 @@ class ServerProcessor(Processor):
                                      "address":s.address, 
                                      "version":s.version, 
                                      "subscriptions":len(s.subscriptions)}, 
-                         self.dispatcher.request_dispatcher.sessions)
+                         self.dispatcher.request_dispatcher.get_sessions())
 
         else:
             print "unknown method", request
index 20fdbfd..4cbaa85 100644 (file)
@@ -143,6 +143,10 @@ class RequestDispatcher(threading.Thread):
         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: