Permalink
Browse files

Added a Tornado adapter. Thanks to montylounge for the patch.

Also added some baseline benchmarks.
  • Loading branch information...
1 parent ead1f7d commit 55177fd6b8c9e6be4cf52be1e0854bd9e964ec4e @toastdriven committed Dec 19, 2009
Showing with 56 additions and 9 deletions.
  1. +2 −1 AUTHORS
  2. +32 −0 benchmarks.rst
  3. +3 −2 examples/alternate_servers.py
  4. +15 −1 itty.py
  5. +4 −5 setup.py
View
@@ -11,4 +11,5 @@ Contributors:
* marly for a patch to an exception's message.
* tstromberg for a patch related to printing tracebacks on errors.
* mronge for a patch to the static files example.
- * Chris Wanstrath (defunkt) for static files patches & suggestions.
+ * Chris Wanstrath (defunkt) for static files patches & suggestions.
+ * Kevin Fricovsky (montylounge) for the Tornado adapter.
View
@@ -0,0 +1,32 @@
+==========
+Benchmarks
+==========
+
+There are lies, damned lies and statistics... and benchmarks.
+
+Run using ``siege`` on the ``examples/alternate_servers.py`` file. Performed on
+a 2008 MacBook Pro.
+
+* ``siege -c 1 -b http://localhost:8080``
+* ``siege -c 10 -b http://localhost:8080``
+* ``siege -c 100 -b http://localhost:8080``
+
++-----------+----------+------------+-------------+
+| Server | 1 Client | 10 Clients | 100 Clients |
++-----------+----------+------------+-------------+
+| wsgiref | 2 | 17 | N/A |
++-----------+----------+------------+-------------+
+| twisted | 348 | 426 | 408 |
++-----------+----------+------------+-------------+
+| diesel | 901 | 1373 | 1295 |
++-----------+----------+------------+-------------+
+| tornado | 962 | 1427 | 1380 |
++-----------+----------+------------+-------------+
+| cherrypy | ??? | ??? | ??? |
++-----------+----------+------------+-------------+
+| flup | ??? | ??? | ??? |
++-----------+----------+------------+-------------+
+| paste | ??? | ??? | ??? |
++-----------+----------+------------+-------------+
+| appengine | ??? | ??? | ??? |
++-----------+----------+------------+-------------+
@@ -8,9 +8,10 @@ def index(request):
# Same as above: run_itty(server='wsgiref')
# Other options:
+# run_itty(server='tornado')
+# run_itty(server='diesel')
+# run_itty(server='twisted')
# run_itty(server='appengine')
# run_itty(server='cherrypy')
# run_itty(server='flup')
# run_itty(server='paste')
-# run_itty(server='twisted')
-# run_itty(server='diesel')
View
16 itty.py
@@ -32,7 +32,7 @@ def index(request):
from cgi import parse_qs
__author__ = 'Daniel Lindsley'
-__version__ = ('0', '6', '3')
+__version__ = ('0', '6', '4')
__license__ = 'BSD'
@@ -477,6 +477,18 @@ def diesel_adapter(host, port):
app.run()
+def tornado_adapter(host, port):
+ # Experimental (Mostly untested).
+ from tornado.wsgi import WSGIContainer
+ from tornado.httpserver import HTTPServer
+ from tornado.ioloop import IOLoop
+
+ container = WSGIContainer(handle_request)
+ http_server = HTTPServer(container)
+ http_server.listen(port)
+ IOLoop.instance().start()
+
+
WSGI_ADAPTERS = {
'wsgiref': wsgiref_adapter,
'appengine': appengine_adapter,
@@ -485,8 +497,10 @@ def diesel_adapter(host, port):
'paste': paste_adapter,
'twisted': twisted_adapter,
'diesel': diesel_adapter,
+ 'tornado': tornado_adapter,
}
+
# Server
def run_itty(server='wsgiref', host='localhost', port=8080, config=None):
View
@@ -1,8 +1,6 @@
#!/usr/bin/env python
-
from distutils.core import setup
import os
-from itty import __version__
long_desc = ''
@@ -12,16 +10,17 @@
# The description isn't worth a failed install...
pass
-classifiers = ['License :: OSI Approved :: BSD License']
setup(
name='itty',
- version='%s.%s.%s' % __version__,
+ version='0.6.4',
description='The itty-bitty Python web framework.',
long_description=long_desc,
author='Daniel Lindsley',
author_email='daniel@toastdriven.com',
url='http://github.com/toastdriven/itty/',
py_modules=['itty'],
license='BSD',
- classifiers=classifiers,
+ classifiers=[
+ 'License :: OSI Approved :: BSD License'
+ ],
)

0 comments on commit 55177fd

Please sign in to comment.