From 1d30e73ab0c7e56c8b83616ee27aa81f35f23cd5 Mon Sep 17 00:00:00 2001 From: Nick Steel Date: Sat, 20 Oct 2018 18:20:38 +0100 Subject: [PATCH] http: use current Tornado IOLoop when stopping. (Fixes #1715). This is in response to the breaking change in Tornado v5.0 where IOLoop.instance is now a deprecated alias for IOLoop.current. More info at https://www.tornadoweb.org/en/stable/releases/v5.0.0.html --- docs/changelog.rst | 7 +++++++ mopidy/http/actor.py | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index b6d7d1b6..a8cc3e65 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,13 @@ Changelog 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) =================== diff --git a/mopidy/http/actor.py b/mopidy/http/actor.py index 8b4835da..1e0e594c 100644 --- a/mopidy/http/actor.py +++ b/mopidy/http/actor.py @@ -100,20 +100,21 @@ class HttpServer(threading.Thread): self.app = None self.server = None + self.io_loop = None def run(self): self.app = tornado.web.Application(self._get_request_handlers()) self.server = tornado.httpserver.HTTPServer(self.app) 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') def stop(self): logger.debug('Stopping HTTP server') - tornado.ioloop.IOLoop.instance().add_callback( - tornado.ioloop.IOLoop.instance().stop) + self.io_loop.add_callback(self.io_loop.stop) def _get_request_handlers(self): request_handlers = []