Commit bc737ae9 authored by echel0n's avatar echel0n

Merge branch 'upgrade/webserver' into develop

# Conflicts:
#	changelog.md
parents 97cf6049 ade442db
# Changelog
- * 0a44429 - 2018-12-02: Pre-Release v9.4.48.dev8
- * ade442d - 2018-12-02: Upgraded to Tornado 5.1.1 Refactored IOLoop placement.
- * 97cf604 - 2018-12-02: Pre-Release v9.4.48.dev8
- * 977b8be - 2018-12-02: Reverted tornado back to v4.5.2
- * 4e68fe8 - 2018-12-01: Pre-Release v9.4.48.dev7
- * bb861f9 - 2018-12-01: Updated message regarding installation of requirements if needed.
......
......@@ -81,7 +81,7 @@ class Core(object):
def __init__(self):
self.started = False
self.daemon = None
self.io_loop = IOLoop()
self.io_loop = None
self.pid = os.getpid()
self.showlist = []
......@@ -155,6 +155,7 @@ class Core(object):
def start(self):
self.started = True
self.io_loop = IOLoop.current()
# thread name
threading.currentThread().setName('CORE')
......@@ -545,7 +546,8 @@ class Core(object):
self.started = False
self.io_loop.stop()
if self.io_loop:
self.io_loop.stop()
def save_all(self):
# write all shows
......
......@@ -31,15 +31,12 @@ from urlparse import urlparse, urljoin
import dateutil.tz
import markdown2
import tornado.gen
import tornado.locale
from concurrent.futures import ThreadPoolExecutor
from mako.exceptions import RichTraceback
from mako.lookup import TemplateLookup
from requests import HTTPError
from tornado.concurrent import run_on_executor
from tornado.escape import json_encode, recursive_unicode
from tornado.gen import coroutine
from tornado.process import cpu_count
from tornado.web import RequestHandler, authenticated
import sickrage
......@@ -87,7 +84,6 @@ from sickrage.providers import NewznabProvider, TorrentRssProvider
class BaseHandler(RequestHandler):
def __init__(self, application, request, **kwargs):
super(BaseHandler, self).__init__(application, request, **kwargs)
self.executor = ThreadPoolExecutor(cpu_count())
self.startTime = time.time()
# template settings
......@@ -202,7 +198,6 @@ class BaseHandler(RequestHandler):
def render(self, template_name, **kwargs):
return self.render_string(template_name, **kwargs)
@run_on_executor
def worker(self, function, **kwargs):
threading.currentThread().setName("TORNADO")
kwargs = recursive_unicode(kwargs)
......@@ -232,17 +227,15 @@ class WebHandler(BaseHandler):
def __init__(self, *args, **kwargs):
super(WebHandler, self).__init__(*args, **kwargs)
@coroutine
@authenticated
@tornado.gen.coroutine
def get(self, *args, **kwargs):
result = yield self.route()
if result: self.write(result)
self.write(self.route())
@coroutine
@authenticated
@tornado.gen.coroutine
def post(self, *args, **kwargs):
result = yield self.route()
if result: self.write(result)
self.write(self.route())
def route(self):
# route -> method obj
......@@ -251,7 +244,8 @@ class WebHandler(BaseHandler):
getattr(self, 'index', None)
)
if method: return self.worker(method, **self.request.arguments)
if method:
return self.worker(method, **self.request.arguments)
def _genericMessage(self, subject, message):
return self.render(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment