-
Notifications
You must be signed in to change notification settings - Fork 362
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
Use tornado's AnyThreadEventLoopPolicy #991
base: master
Are you sure you want to change the base?
Conversation
Since tornado 5.0 (with python 3), event loops by default have to be created explicitly in each new thread. This commit reinstates the old behavior in AWS and CWS. http://www.tornadoweb.org/en/stable/asyncio.html#tornado.platform.asyncio.AnyThreadEventLoopPolicy
d4bdbc8
to
a9f81cb
Compare
Codecov Report
@@ Coverage Diff @@
## master #991 +/- ##
==========================================
- Coverage 65.05% 64.82% -0.24%
==========================================
Files 230 230
Lines 17731 17731
==========================================
- Hits 11535 11494 -41
- Misses 6196 6237 +41
Continue to review full report at Codecov.
|
Your change is breaking the functional tests. The policy you are using was introduced in Tornado 5.0. The tests pin it to 4.5, as in Ubuntu 18.04. |
Yes, sorry! I've added a check for "tornado version >= 5.0" now. |
Ok, the commit you just pushed should fix that. I'm not understanding however what you're trying to fix. The Tornado doc page you link mentions utils for bridging Tornado with asyncio. Your code also imports asyncio. We're not using asyncio, however, so how can it cause problems? |
I was getting errors like this when opening the AWS web page:
|
In case that helps, here's another reference to the AnyThreadEventLoopPolicy fix: |
Tornado should have nothing to do with IO loops or asynchronicity. We take care of it, through gevent, and just use Tornado via WSGI for routing and handling. I didn't look deep into it (yet) but it appears that v5 became "asyncio-only", which could mean that asyncio stuff has creeped into places where it shouldn't be. I don't think we should tolerate Tornado's use of asyncio, so the fix for this issue should go another way (in your fix, Tornado would start an asyncio loop, which most likely won't play nicely with gevent, be starved, and lead to who knows what chaos). While I was looking at the changelog I read that they deprecated WSGI support (as if one could ever have called it "support") and will remove it in v6. Maybe it's time to replace Tornado by something else. Or to replace gevent by asyncio. Let's see what @stefano-maggiolo is less disgusted by. |
I suppose removing Tornado is more pressing. There are talks to have gevent and asyncio play nice and include that in gevent... gevent/gevent#982 |
I get the same error. Ubuntu 18.10 seems to install tornado 5.0.2 |
Tornado still remains pinned to the 4.x series (see cms-dev#991). Fortunately, Ubuntu 20.04 has a python3-tornado4 package, which provides just that.
Since tornado 5.0 (with python 3), event loops by default have to be created explicitly in each new thread. This commit reinstates the old behavior in AWS and CWS.
http://www.tornadoweb.org/en/stable/asyncio.html#tornado.platform.asyncio.AnyThreadEventLoopPolicy
Apparently, the alternative is to create a new event loop inside each new thread, as described here: tornadoweb/tornado#2183
I wasn't sure where to set the AnyThreadEventLoopPolicy, but the top of main() seemed reasonable...
RWS seems to work without this change.
This change is