Merge branch 'develop' of github.com:RuudBurger/CouchPotatoServer into develop
This commit is contained in:
@@ -10,6 +10,7 @@ from couchpotato.environment import Env
|
|||||||
from sqlalchemy.sql.expression import or_
|
from sqlalchemy.sql.expression import or_
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
import traceback
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
@@ -146,6 +147,8 @@ class CoreNotifier(Notification):
|
|||||||
|
|
||||||
def frontend(self, type = 'notification', data = {}, message = None):
|
def frontend(self, type = 'notification', data = {}, message = None):
|
||||||
|
|
||||||
|
log.debug('Notifying frontend')
|
||||||
|
|
||||||
self.m_lock.acquire()
|
self.m_lock.acquire()
|
||||||
notification = {
|
notification = {
|
||||||
'message_id': str(uuid.uuid4()),
|
'message_id': str(uuid.uuid4()),
|
||||||
@@ -164,11 +167,14 @@ class CoreNotifier(Notification):
|
|||||||
'result': [notification],
|
'result': [notification],
|
||||||
})
|
})
|
||||||
except:
|
except:
|
||||||
|
log.debug('Failed sending to listener: %s', traceback.format_exc())
|
||||||
break
|
break
|
||||||
|
|
||||||
self.m_lock.release()
|
self.m_lock.release()
|
||||||
self.cleanMessages()
|
self.cleanMessages()
|
||||||
|
|
||||||
|
log.debug('Done notifying frontend')
|
||||||
|
|
||||||
def addListener(self, callback, last_id = None):
|
def addListener(self, callback, last_id = None):
|
||||||
|
|
||||||
if last_id:
|
if last_id:
|
||||||
@@ -190,9 +196,11 @@ class CoreNotifier(Notification):
|
|||||||
if listener == callback:
|
if listener == callback:
|
||||||
self.listeners.remove(list_tuple)
|
self.listeners.remove(list_tuple)
|
||||||
except:
|
except:
|
||||||
pass
|
log.debug('Failed removing listener: %s', traceback.format_exc())
|
||||||
|
|
||||||
def cleanMessages(self):
|
def cleanMessages(self):
|
||||||
|
|
||||||
|
log.debug('Cleaning messages')
|
||||||
self.m_lock.acquire()
|
self.m_lock.acquire()
|
||||||
|
|
||||||
for message in self.messages:
|
for message in self.messages:
|
||||||
@@ -200,8 +208,11 @@ class CoreNotifier(Notification):
|
|||||||
self.messages.remove(message)
|
self.messages.remove(message)
|
||||||
|
|
||||||
self.m_lock.release()
|
self.m_lock.release()
|
||||||
|
log.debug('Done cleaning messages')
|
||||||
|
|
||||||
def getMessages(self, last_id):
|
def getMessages(self, last_id):
|
||||||
|
|
||||||
|
log.debug('Getting messages with id: %s', last_id)
|
||||||
self.m_lock.acquire()
|
self.m_lock.acquire()
|
||||||
|
|
||||||
recent = []
|
recent = []
|
||||||
@@ -212,6 +223,7 @@ class CoreNotifier(Notification):
|
|||||||
recent = self.messages[index:]
|
recent = self.messages[index:]
|
||||||
|
|
||||||
self.m_lock.release()
|
self.m_lock.release()
|
||||||
|
log.debug('Returning for %s %s messages', (last_id, len(recent or [])))
|
||||||
|
|
||||||
return recent or []
|
return recent or []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user