From ed1ae6e81a6d0d7b95c51f9ec8e95463a85978d6 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 26 May 2012 23:12:48 +0200 Subject: [PATCH] Aquire lock for long poll --- couchpotato/core/notifications/core/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/couchpotato/core/notifications/core/main.py b/couchpotato/core/notifications/core/main.py index 6a299c48..196a9ac1 100644 --- a/couchpotato/core/notifications/core/main.py +++ b/couchpotato/core/notifications/core/main.py @@ -165,6 +165,7 @@ class CoreNotifier(Notification): self.listeners.append((callback, last_id)) def removeListener(self, callback): + self.m_lock.aquire() for list_tuple in self.listeners: try: listener, last_id = list_tuple @@ -172,12 +173,15 @@ class CoreNotifier(Notification): self.listeners.remove(list_tuple) except: pass + self.m_lock.release() def cleanMessages(self): + self.m_lock.aquire() for message in self.messages: if message['time'] < (time.time() - 15): self.messages.remove(message) + self.m_lock.release() def getMessages(self, last_id): self.m_lock.acquire()