New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix websocket broadcasts in Tornado 5.x #1796
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In Tornado 4.x and earlier, IOLoop.current() would return the global IOLoop if there was no IOLoop already running in the calling thread. This was the case when calling our websocket broadcast method from the HttpFrontend thread and so callbacks were correctly scheduled on the HttpServer thread's IOLoop. However, in Tornado 5.0+, the idea of a global IOLoop is gone and calling IOLoop.current() will simply create a new IOLoop if there isn't one already running in the calling thread. This incorrectly resulted in callbacks being scheduled on that new IOLoop which is never actually started and so the broadcasts were never sent. This is related to mopidy#1716.
jodal
approved these changes
Sep 8, 2019
62b065a
to
de75e3f
Compare
de75e3f
to
5af8fc7
Compare
Wow, the fact I managed to mess up that fixup and the tests still passed is really still a bit of an issue... |
Not entirely with you. Is it anything that should be fixed before merging? |
Nah, false alarm, it's good to go. |
jodal
pushed a commit
that referenced
this issue
Sep 30, 2019
In Tornado 4.x and earlier, IOLoop.current() would return the global IOLoop if there was no IOLoop already running in the calling thread. This was the case when calling our websocket broadcast method from the HttpFrontend thread and so callbacks were correctly scheduled on the HttpServer thread's IOLoop. However, in Tornado 5.0+, the idea of a global IOLoop is gone and calling IOLoop.current() will simply create a new IOLoop if there isn't one already running in the calling thread. This incorrectly resulted in callbacks being scheduled on that new IOLoop which is never actually started and so the broadcasts were never sent. This is related to #1716. (cherry picked from commit 59a3935)
15 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
In Tornado 4.x and earlier,
IOLoop.current()
would return the global IOLoopif there was no IOLoop already running in the calling thread. This was the
case when calling our websocket handler's
broadcast
method from theHttpFrontend
threadand so callbacks were correctly scheduled on the
HttpServer
thread's IOLoop.However, in Tornado 5.0+, the idea of a global IOLoop is gone and calling
IOLoop.current()
will simply create a new IOLoop if there isn't one alreadyrunning in the calling thread.
This incorrectly resulted in callbacks being scheduled on that new IOLoop
which is never actually started and so the broadcasts were never sent.
To fix this we explicitly provide
broadcast
with the correct IOLoop to use (HttpServer
's).Also,
tornado.websocket.websocket_connect
removed the io_loop parameter, which we don't seem to need. I gave up trying to get the tests to fail under Tornado 5.x.This is related to #1716.