diff --git a/couchpotato/__init__.py b/couchpotato/__init__.py index 8dc691da..11d8de93 100644 --- a/couchpotato/__init__.py +++ b/couchpotato/__init__.py @@ -25,7 +25,7 @@ class WebHandler(RequestHandler): if not views.get(route): page_not_found(self) return - self.write(views[route]()) + self.finish(views[route]()) def addView(route, func, static = False): views[route] = func @@ -64,7 +64,7 @@ class KeyHandler(RequestHandler): if (self.get_argument('u') == md5(username) or not username) and (self.get_argument('p') == password or not password): api = Env.setting('api_key') - self.write({ + self.finish({ 'success': api is not None, 'api_key': api }) @@ -81,5 +81,5 @@ def page_not_found(rh): time.sleep(0.1) rh.set_status(404) - rh.write('Wrong API key used') + rh.finish('Wrong API key used') diff --git a/couchpotato/api.py b/couchpotato/api.py index 7020fd93..0488ee43 100644 --- a/couchpotato/api.py +++ b/couchpotato/api.py @@ -49,7 +49,7 @@ class ApiHandler(RequestHandler): def get(self, route, *args, **kwargs): route = route.strip('/') if not api.get(route): - self.write('API call doesn\'t seem to exist') + self.finish('API call doesn\'t seem to exist') return kwargs = {} @@ -68,11 +68,11 @@ class ApiHandler(RequestHandler): jsonp_callback = self.get_argument('callback_func', default = None) if jsonp_callback: - self.write(str(jsonp_callback) + '(' + json.dumps(result) + ')') + self.finish(str(jsonp_callback) + '(' + json.dumps(result) + ')') elif isinstance(result, (tuple)) and result[0] == 'redirect': self.redirect(result[1]) else: - self.write(result) + self.finish(result) def addApiView(route, func, static = False, docs = None, **kwargs): diff --git a/couchpotato/core/notifications/core/main.py b/couchpotato/core/notifications/core/main.py index a6ce2a63..0d75c281 100644 --- a/couchpotato/core/notifications/core/main.py +++ b/couchpotato/core/notifications/core/main.py @@ -19,7 +19,7 @@ log = CPLog(__name__) class CoreNotifier(Notification): - m_lock = threading.Lock() + m_lock = None def __init__(self): super(CoreNotifier, self).__init__() @@ -57,6 +57,7 @@ class CoreNotifier(Notification): self.messages = [] self.listeners = [] + self.m_lock = threading.Lock() def clean(self): @@ -222,7 +223,7 @@ class CoreNotifier(Notification): recent = [] try: index = map(itemgetter('message_id'), self.messages).index(last_id) - recent = self.messages[index+1:] + recent = self.messages[index + 1:] except: pass