From 576bcb9f4b389d271da6a88addb50405c8f21dff Mon Sep 17 00:00:00 2001 From: Ruud Date: Fri, 19 Dec 2014 08:57:24 +0100 Subject: [PATCH] Give response back to the main thread on api calls fix #4337 --- couchpotato/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/couchpotato/api.py b/couchpotato/api.py index cd01197..3602513 100644 --- a/couchpotato/api.py +++ b/couchpotato/api.py @@ -7,6 +7,7 @@ import urllib from couchpotato.core.helpers.request import getParams from couchpotato.core.logger import CPLog +from tornado.ioloop import IOLoop from tornado.web import RequestHandler, asynchronous @@ -33,7 +34,7 @@ def run_async(func): def run_handler(route, kwargs, callback = None): try: res = api[route](**kwargs) - callback(res, route) + IOLoop.instance().add_callback(callback, res, route) except: log.error('Failed doing api request "%s": %s', (route, traceback.format_exc())) callback({'success': False, 'error': 'Failed returning results'}, route)