cms-dev / cms-dev/cms

Stop using Tornado 4.5.3

Open
#1,442 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1k
Forks
412
Avg merge
6d 10h
Merged PRs (30d)
3

Description

Tornado 4.5.3 is over 7 years old. We can't keep using it forever.

See also: #991

From what I understood, there are two problems:

  • Tornado 5.0 started using asyncio internally.
  • Tornado 6.0 entirely removed WSGI support.

gevent doesn't play nice with asyncio by default. There are some snippets on the internet that attempt to integrate gevent's and asyncio's event loops, but none of them look particularly well-maintained to me (but they aren't very big, so we would probably end up copy-pasting one and maintaining it ourselves).

Replacing gevent with asyncio would probably be quite a big project: we need to add async/await everywhere, and we need to improve test coverage to make sure we don't forget any awaits.

So we have a few options:

  • Upgrade Tornado, rewrite all our WSGI middlewares, replace gevent with asyncio.
  • Upgrade Tornado, rewrite all our WSGI middlewares, implement a compatibility hack to use gevent and asyncio together.
  • Replace Tornado with some other WSGI-friendly framework, rewrite all of our request-handling. (Optionally we can still replace gevent with asyncio later.)

Personally, I have a mild distaste for gevent in general, and would prefer replacing it with asyncio. I don't have much experience with other web frameworks so I don't know much about tornado vs other possible web frameworks. At a glance, our WSGI middlewares all look like things that could be implemented using regular Tornado request handlers, but maybe I missed some complications.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the WSGI middlewares and request-handling code, then read the discussion in #991. Compare the Tornado, gevent, and asyncio constraints described here and inspect existing test coverage. Done requires choosing and implementing a migration path away from Tornado 4.5.3, with middleware and asynchronous behavior covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, web-dev
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.