Skip to content
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

http: use current Tornado IOLoop when stopping. (Fixes #1715). #1716

Merged
merged 1 commit into from Oct 22, 2018

Conversation

kingosticks
Copy link
Member

From Tornado v5.0:

IOLoop.instance is now a deprecated alias for IOLoop.current. Applications that need the cross-thread communication behavior facilitated by IOLoop.instance should use their own global variable instead.

We were using IOLoop.instance to stop the HTTP server thread from a different thread.

Copy link
Member

@jodal jodal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this works for Tornado 4.4 and upwards?

@kingosticks
Copy link
Member Author

Yep I did a few tests on both tornado 5 and 4.4, seems fine.

@jodal
Copy link
Member

jodal commented Oct 21, 2018

Maybe target this for the release-2.2 branch? And add a changelog entry.

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
@kingosticks kingosticks changed the base branch from develop to release-2.2 October 22, 2018 14:33
@jodal jodal added this to the v2.2.2 milestone Oct 22, 2018
@jodal jodal added the A-http Area: HTTP frontend label Oct 22, 2018
@jodal jodal merged commit 10c571b into mopidy:release-2.2 Oct 22, 2018
kingosticks added a commit to kingosticks/mopidy that referenced this pull request Sep 8, 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 mopidy#1716.
kingosticks added a commit that referenced this pull request Sep 9, 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.
@kingosticks kingosticks mentioned this pull request Sep 9, 2019
3 tasks
jodal pushed a commit that referenced this pull request 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-http Area: HTTP frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants