http: Finally fix the old tornado broadcast bug.

This commit is contained in:
Thomas Adamcik 2015-04-27 22:52:12 +02:00
parent f90e512ede
commit 83e54b090b
2 changed files with 11 additions and 2 deletions

View File

@ -4,6 +4,13 @@ Changelog
This changelog is used to track all major changes to Mopidy.
v1.0.3 (unreleased)
===================
- HTTP: An other follow-up to the pre 3.0 fixing. Since the tests aren't run
for 2.3 we didn't catch that our previous fix wasn't sufficient.
(Fixes: :issue:`1153`)
v1.0.2 (2015-04-27)
===================

View File

@ -1,5 +1,6 @@
from __future__ import absolute_import, unicode_literals
import functools
import logging
import os
import socket
@ -91,13 +92,14 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler):
if hasattr(tornado.ioloop.IOLoop, 'current'):
loop = tornado.ioloop.IOLoop.current()
else:
loop = tornado.ioloop.IOLoop.instance() # Fallback for 2.3
loop = tornado.ioloop.IOLoop.instance() # Fallback for pre 3.0
# 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
loop.add_callback(_send_broadcast, client, msg)
# NOTE: Pre 3.0 does not support *args or **kwargs...
loop.add_callback(functools.partial(_send_broadcast, client, msg))
def initialize(self, core):
self.jsonrpc = make_jsonrpc_wrapper(core)