Skip to content

Commit

Permalink
Factor the Tornado application through a WSGI interface.
Browse files Browse the repository at this point in the history
This commits actually makes *WS slower and in theory less powerful.
It is only a "just-because-we-can-commit", in order to check whether
our current code factors well through a WSGI interface.

Of course this doesn't involve RWS: it is known that RWS doesn't
factor well through a WSGI interface.
  • Loading branch information
giomasce committed Jun 2, 2013
1 parent c8335fe commit 6c71700
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cms/async/WebAsyncLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

# Programming contest management system
# Copyright © 2010-2012 Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
# Copyright © 2010-2013 Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
# Copyright © 2010-2012 Stefano Maggiolo <s.maggiolo@gmail.com>
# Copyright © 2010-2012 Matteo Boscariol <boscarim@hotmail.com>
#
Expand Down Expand Up @@ -31,6 +31,7 @@
import tornado.ioloop
import tornado.web
import tornado.escape
import tornado.wsgi

from cms.async import ServiceCoord
from cms.async.AsyncLibrary import Service, rpc_callback
Expand Down Expand Up @@ -177,7 +178,7 @@ def __init__(self, listen_port, handlers, parameters, shard=0,
(r"/sync_rpc_request/([a-zA-Z0-9_-]+)/" \
"([0-9]+)/([a-zA-Z0-9_-]+)",
SyncRPCRequestHandler)]
self.application = tornado.web.Application(handlers, **parameters)
self.application = tornado.wsgi.WSGIApplication(handlers, **parameters)

# xheaders=True means that Tornado uses the content of the
# header X-Real-IP as the request IP. This means that if it is
Expand All @@ -186,8 +187,10 @@ def __init__(self, listen_port, handlers, parameters, shard=0,
# (i.e., if we are not behind a proxy that sets that header,
# we must not use it).
self.application.service = self
self.wsgi_container = tornado.wsgi.WSGIContainer(self.application)
http_server = tornado.httpserver.HTTPServer(
self.application, xheaders=parameters.get("is_proxy_used", True))
self.wsgi_container,
xheaders=parameters.get("is_proxy_used", True))
http_server.listen(listen_port, address=listen_address)
self.instance = tornado.ioloop.IOLoop.instance()

Expand Down

0 comments on commit 6c71700

Please sign in to comment.