Merge pull request #1716 from kingosticks/fix/hang-on-stopping-http

http: use current Tornado IOLoop when stopping. (Fixes #1715).
This commit is contained in:
Stein Magnus Jodal 2018-10-22 22:06:31 +02:00 committed by GitHub
commit 10c571b153
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -5,6 +5,13 @@ Changelog
This changelog is used to track all major changes to Mopidy. This changelog is used to track all major changes to Mopidy.
v2.2.2 (UNRELEASED)
===================
- HTTP: Fix hang on exit due to change in Tornado v5.0 IOLoop. (Fixes:
:issue:`1715`, PR: :issue:`1716`)
v2.2.1 (2018-10-15) v2.2.1 (2018-10-15)
=================== ===================

View File

@ -100,20 +100,21 @@ class HttpServer(threading.Thread):
self.app = None self.app = None
self.server = None self.server = None
self.io_loop = None
def run(self): def run(self):
self.app = tornado.web.Application(self._get_request_handlers()) self.app = tornado.web.Application(self._get_request_handlers())
self.server = tornado.httpserver.HTTPServer(self.app) self.server = tornado.httpserver.HTTPServer(self.app)
self.server.add_sockets(self.sockets) self.server.add_sockets(self.sockets)
tornado.ioloop.IOLoop.instance().start() self.io_loop = tornado.ioloop.IOLoop.current()
self.io_loop.start()
logger.debug('Stopped HTTP server') logger.debug('Stopped HTTP server')
def stop(self): def stop(self):
logger.debug('Stopping HTTP server') logger.debug('Stopping HTTP server')
tornado.ioloop.IOLoop.instance().add_callback( self.io_loop.add_callback(self.io_loop.stop)
tornado.ioloop.IOLoop.instance().stop)
def _get_request_handlers(self): def _get_request_handlers(self):
request_handlers = [] request_handlers = []