Browse Source

Give response back to the main thread on api calls

fix #4337
pull/4380/head
Ruud 11 years ago
parent
commit
576bcb9f4b
  1. 3
      couchpotato/api.py

3
couchpotato/api.py

@ -7,6 +7,7 @@ import urllib
from couchpotato.core.helpers.request import getParams from couchpotato.core.helpers.request import getParams
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from tornado.ioloop import IOLoop
from tornado.web import RequestHandler, asynchronous from tornado.web import RequestHandler, asynchronous
@ -33,7 +34,7 @@ def run_async(func):
def run_handler(route, kwargs, callback = None): def run_handler(route, kwargs, callback = None):
try: try:
res = api[route](**kwargs) res = api[route](**kwargs)
callback(res, route) IOLoop.instance().add_callback(callback, res, route)
except: except:
log.error('Failed doing api request "%s": %s', (route, traceback.format_exc())) log.error('Failed doing api request "%s": %s', (route, traceback.format_exc()))
callback({'success': False, 'error': 'Failed returning results'}, route) callback({'success': False, 'error': 'Failed returning results'}, route)

Loading…
Cancel
Save