Skip to content

Commit

Permalink
Use tornado's AnyThreadEventLoopPolicy
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fagu committed Aug 16, 2018
1 parent e02ac17 commit a9f81cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions scripts/cmsAdminWebServer
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ gevent.monkey.patch_all()

import logging
import sys
import tornado

from cms import ConfigError, default_argument_parser
from cms.db import test_db_connection
Expand All @@ -45,6 +46,11 @@ def main():
"""Parse arguments and launch service.
"""
if tornado.version_info >= (5, 0):
import asyncio
from tornado.platform.asyncio import AnyThreadEventLoopPolicy
asyncio.set_event_loop_policy(AnyThreadEventLoopPolicy())

test_db_connection()
success = default_argument_parser("Admins' web server for CMS.",
AdminWebServer).run()
Expand Down
6 changes: 6 additions & 0 deletions scripts/cmsContestWebServer
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ gevent.monkey.patch_all()

import logging
import sys
import tornado

from cms import ConfigError, default_argument_parser
from cms.db import ask_for_contest, test_db_connection
Expand All @@ -45,6 +46,11 @@ def main():
"""Parse arguments and launch service.
"""
if tornado.version_info >= (5, 0):
import asyncio
from tornado.platform.asyncio import AnyThreadEventLoopPolicy
asyncio.set_event_loop_policy(AnyThreadEventLoopPolicy())

test_db_connection()
success = default_argument_parser("Contestants' web server for CMS.",
ContestWebServer,
Expand Down

0 comments on commit a9f81cb

Please sign in to comment.