From bbeb5c03aa5f85c4e3cb64b98965c1d237a48c39 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Wed, 26 Oct 2016 00:35:36 +0200 Subject: [PATCH] Require Tornado >= 3.2 Survey of version available in the oldest distros we care about: - Debian 8, squeeze: 3.2.2 - Debian 8, squeeze-backports: 4.2.0 - Ubuntu 16.04 LTS: 4.2.1 - Arch Linux: 4.4.2 --- .travis.yml | 3 +-- docs/changelog.rst | 5 +++++ mopidy/http/handlers.py | 11 ++--------- setup.py | 2 +- tox.ini | 12 +++--------- 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index f46d5ae2..73b3e20c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,7 @@ python: env: - TOX_ENV=py27 - - TOX_ENV=py27-tornado23 - - TOX_ENV=py27-tornado31 + - TOX_ENV=py27-tornado32 - TOX_ENV=docs - TOX_ENV=flake8 diff --git a/docs/changelog.rst b/docs/changelog.rst index 3b213d71..03bca901 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -10,6 +10,11 @@ v2.1.0 (UNRELEASED) Feature release. +- Dependencies: Drop support for Tornado < 3.2. Though strictly a breaking + change, this shouldn't have any effect on what systems we support, as Tornado + 3.2 or newer is available from the distros that include GStreamer >= 1.2.3, + which we already require. + - Core: Mopidy restores its last state when started. Can be enabled by setting the config value :confval:`core/restore_state` to ``true``. diff --git a/mopidy/http/handlers.py b/mopidy/http/handlers.py index a752a4f0..479cb3a0 100644 --- a/mopidy/http/handlers.py +++ b/mopidy/http/handlers.py @@ -89,16 +89,12 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler): @classmethod def broadcast(cls, msg): - if hasattr(tornado.ioloop.IOLoop, 'current'): - loop = tornado.ioloop.IOLoop.current() - else: - loop = tornado.ioloop.IOLoop.instance() # Fallback for pre 3.0 + loop = tornado.ioloop.IOLoop.current() # This can be called from outside the Tornado ioloop, so we need to # safely cross the thread boundary by adding a callback to the loop. for client in cls.clients: # One callback per client to keep time we hold up the loop short - # NOTE: Pre 3.0 does not support *args or **kwargs... loop.add_callback(functools.partial(_send_broadcast, client, msg)) def initialize(self, core): @@ -139,10 +135,7 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler): except Exception as e: error_msg = encoding.locale_decode(e) logger.error('WebSocket request error: %s', error_msg) - if self.ws_connection: - # Tornado 3.2+ checks if self.ws_connection is None before - # using it, but not older versions. - self.close() + self.close() def check_origin(self, origin): # Allow cross-origin WebSocket connections, like Tornado before 4.0 diff --git a/setup.py b/setup.py index a353a932..d41c943d 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ setup( 'Pykka >= 1.1', 'requests >= 2.0', 'setuptools', - 'tornado >= 2.3', + 'tornado >= 3.2', ], extras_require={'http': []}, entry_points={ diff --git a/tox.ini b/tox.ini index da6bcc38..d5bed67d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, py27-tornado23, py27-tornado31, docs, flake8 +envlist = py27, py27-tornado32, docs, flake8 [testenv] sitepackages = true @@ -17,17 +17,11 @@ deps = pytest-xdist responses -[testenv:py27-tornado23] +[testenv:py27-tornado32] commands = py.test tests/http deps = {[testenv]deps} - tornado==2.3 - -[testenv:py27-tornado31] -commands = py.test tests/http -deps = - {[testenv]deps} - tornado==3.1.1 + tornado==3.2.2 [testenv:docs] deps = -r{toxinidir}/docs/requirements.txt