From 29462e2278450253cacd3ac2735d1cd650c3f21b Mon Sep 17 00:00:00 2001 From: Jack Darlington Date: Mon, 13 Mar 2017 00:44:20 +0000 Subject: [PATCH] Fix for updater --- cps/helper.py | 10 +++++++--- cps/web.py | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cps/helper.py b/cps/helper.py index e81f6773..424e1f2b 100755 --- a/cps/helper.py +++ b/cps/helper.py @@ -341,9 +341,13 @@ class Updater(threading.Thread): ub.session.close() ub.engine.dispose() self.status=6 - # stop tornado server - server = IOLoop.instance() - server.add_callback(server.stop) + + if web.gevent_server: + web.gevent_server.stop() + else: + # stop tornado server + server = IOLoop.instance() + server.add_callback(server.stop) self.status=7 def get_update_status(self): diff --git a/cps/web.py b/cps/web.py index fdf57326..4598ed48 100755 --- a/cps/web.py +++ b/cps/web.py @@ -198,6 +198,8 @@ mimetypes.add_type('image/vnd.djvu', '.djvu') app = (Flask(__name__)) app.wsgi_app = ReverseProxied(app.wsgi_app) +gevent_server=None + formatter = logging.Formatter( "[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s") file_handler = RotatingFileHandler(os.path.join(config.get_main_dir, "calibre-web.log"), maxBytes=50000, backupCount=2) @@ -2683,3 +2685,9 @@ def upload(): book_in_shelfs = [] return render_title_template('detail.html', entry=db_book, cc=cc, title=db_book.title, books_shelfs=book_in_shelfs, ) + +def start_gevent(): + from gevent.wsgi import WSGIServer + global gevent_server + gevent_server = WSGIServer(('', ub.config.config_port), app) + gevent_server.serve_forever() \ No newline at end of file