From 1e5d6bad2a12e9502ade14c6d43758b89b2f3daf Mon Sep 17 00:00:00 2001 From: Ruud Date: Sun, 1 Sep 2013 00:24:18 +0200 Subject: [PATCH] Lock while editing listeners --- 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 0d75c281..c3776a87 100644 --- a/couchpotato/core/notifications/core/main.py +++ b/couchpotato/core/notifications/core/main.py @@ -188,11 +188,14 @@ class CoreNotifier(Notification): 'result': messages, }) + self.m_lock.acquire() self.listeners.append((callback, last_id)) + self.m_lock.release() def removeListener(self, callback): + self.m_lock.acquire() for list_tuple in self.listeners: try: listener, last_id = list_tuple @@ -200,6 +203,7 @@ class CoreNotifier(Notification): self.listeners.remove(list_tuple) except: log.debug('Failed removing listener: %s', traceback.format_exc()) + self.m_lock.release() def cleanMessages(self):