Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ovidiucp committed Jun 15, 2012
2 parents 891904c + 4cdc02f commit 72ce4aa
Show file tree
Hide file tree
Showing 110 changed files with 4,621 additions and 1,335 deletions.
18 changes: 18 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Test coverage configuration.
# Usage:
# pip install coverage
# coverage erase # clears previous data if any
# coverage run -m tornado.test.runtests
# coverage report # prints to stdout
# coverage html # creates ./htmlcov/*.html including annotated source
[run]
branch = true
source = tornado
omit =
tornado/platform/*
tornado/test/*
*/_auto2to3*

[report]
# Ignore missing source files, i.e. fake template-generated "files"
ignore_errors = true
13 changes: 9 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
*.pyc
*.pyo
*.so
*.class
*~
build
dist/
build/
/dist/
MANIFEST
tornado.egg-info
/tornado.egg-info/
_auto2to3*
.tox
.tox/
.vagrant
/.coverage
/htmlcov/
/env/
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# http://travis-ci.org/#!/facebook/tornado
language: python
# The build of 2.6 on travis has a bug related to ssl (it segfaults in
# test_sslv2_fail)
python:
- 2.7
- 3.2
# TODO: install pycurl, twisted, etc (depends on python version)
install:
- python setup.py install
script:
# Must cd somewhere else so python3 doesn't get confused and run
# the python2 code from the current directory instead of the installed
# 2to3 version.
- cd maint
- python -m tornado.test.runtests
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ include tornado/ca-certificates.crt
include tornado/test/README
include tornado/test/test.crt
include tornado/test/test.key
include tornado/test/csv_translations/fr_FR.csv
include tornado/test/gettext_translations/fr_FR/LC_MESSAGES/tornado_test.mo
include tornado/test/gettext_translations/fr_FR/LC_MESSAGES/tornado_test.po
include tornado/test/static/robots.txt
include tornado/test/templates/utf8.html
global-exclude _auto2to3*
49 changes: 36 additions & 13 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,49 @@ available at http://www.tornadoweb.org/
Tornado is licensed under the Apache Licence, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.html).

Installation
============
To install:
Automatic installation
----------------------

Tornado is listed in PyPI and can be installed with pip or
easy_install. Note that the source distribution includes demo
applications that are not present when Tornado is installed in this
way, so you may wish to download a copy of the source tarball as well.

Manual installation
-------------------

Download https://github.com/downloads/facebook/tornado/tornado-2.3.tar.gz

tar xvzf tornado-2.3.tar.gz
cd tornado-2.3
python setup.py build
sudo python setup.py install

Tornado has been tested on Python 2.5 and 2.6. To use all of the features
of Tornado, you need to have PycURL and (for Python 2.5 only) simplejson
installed.
The Tornado source code is hosted on GitHub: https://github.com/facebook/tornado

On Python 2.6 and 2.7, it is also possible to simply add the tornado
directory to your PYTHONPATH instead of building with setup.py, since
the standard library includes epoll support.

Prerequisites
-------------

On Mac OS X 10.6, you can install the packages with:
Tornado runs on Python 2.5, 2.6, 2.7 and 3.2.

sudo easy_install pycurl
On Python 2.6 and 2.7, there are no dependencies outside the Python
standard library, although PycURL (version 7.18.2 or higher required;
version 7.21.1 or higher recommended) may be used if desired.

On Ubuntu Linux, you can install the packages with:
On Python 2.5, PycURL is required, along with simplejson and the
Python development headers (typically obtained by installing a package
named something like python-dev from your operating system).

# Python 2.6
sudo apt-get install python-pycurl
On Python 3.2, the distribute package is required. Note that Python 3
support is relatively new and may have bugs.

# Python 2.5
sudo apt-get install python-dev python-pycurl python-simplejson
Platforms
---------

Tornado should run on any Unix-like platform, although for the best
performance and scalability only Linux and BSD (including BSD
derivatives like Mac OS X) are recommended.
47 changes: 47 additions & 0 deletions demos/benchmark/chunk_benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python
#
# Downloads a large file in chunked encoding with both curl and simple clients

import logging
from tornado.curl_httpclient import CurlAsyncHTTPClient
from tornado.simple_httpclient import SimpleAsyncHTTPClient
from tornado.ioloop import IOLoop
from tornado.options import define, options, parse_command_line
from tornado.web import RequestHandler, Application

define('port', default=8888)
define('num_chunks', default=1000)
define('chunk_size', default=2048)

class ChunkHandler(RequestHandler):
def get(self):
for i in xrange(options.num_chunks):
self.write('A' * options.chunk_size)
self.flush()
self.finish()

def main():
parse_command_line()
app = Application([('/', ChunkHandler)])
app.listen(options.port, address='127.0.0.1')
def callback(response):
response.rethrow()
assert len(response.body) == (options.num_chunks * options.chunk_size)
logging.warning("fetch completed in %s seconds", response.request_time)
IOLoop.instance().stop()

logging.warning("Starting fetch with curl client")
curl_client = CurlAsyncHTTPClient()
curl_client.fetch('http://localhost:%d/' % options.port,
callback=callback)
IOLoop.instance().start()

logging.warning("Starting fetch with simple client")
simple_client = SimpleAsyncHTTPClient()
simple_client.fetch('http://localhost:%d/' % options.port,
callback=callback)
IOLoop.instance().start()


if __name__ == '__main__':
main()
4 changes: 4 additions & 0 deletions demos/websocket/chatdemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class ChatSocketHandler(tornado.websocket.WebSocketHandler):
cache = []
cache_size = 200

def allow_draft76(self):
# for iOS 5.0 Safari
return True

def open(self):
ChatSocketHandler.waiters.add(self)

Expand Down
5 changes: 3 additions & 2 deletions demos/websocket/static/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ var updater = {
socket: null,

start: function() {
var url = "ws://" + location.host + "/chatsocket";
if ("WebSocket" in window) {
updater.socket = new WebSocket("ws://localhost:8888/chatsocket");
updater.socket = new WebSocket(url);
} else {
updater.socket = new MozWebSocket("ws://localhost:8888/chatsocket");
updater.socket = new MozWebSocket(url);
}
updater.socket.onmessage = function(event) {
updater.showMessage(JSON.parse(event.data));
Expand Down
3 changes: 0 additions & 3 deletions maint/appengine/README
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ forbidden modules.
The code lives in maint/appengine/common, but should be run from the py25
or py27 subdirectories (which contain an app.yaml and a bunch of symlinks).
runtests.py is the entry point; cgi_runtests.py is used internally.
dev_appserver.py doesn't work with virtualenv
(http://code.google.com/p/googleappengine/issues/detail?id=4339) so these
tests are not hooked into tox yet.
11 changes: 7 additions & 4 deletions maint/appengine/common/cgi_runtests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
import logging
import sys
import unittest

# Most of our tests depend on IOLoop, which is not importable on app engine.
Expand Down Expand Up @@ -57,16 +57,19 @@ def import_everything():
def all():
return unittest.defaultTestLoader.loadTestsFromNames(TEST_MODULES)

if __name__ == '__main__':
def main():
print "Content-Type: text/plain\r\n\r\n",

import_everything()

import tornado.testing
try:
tornado.testing.main()
unittest.main(defaultTest="all", argv=sys.argv)
except SystemExit, e:
if e.code == 0:
print "PASS"
else:
raise

if __name__ == '__main__':
main()

34 changes: 29 additions & 5 deletions maint/appengine/common/runtests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/usr/bin/env python
from __future__ import with_statement

import contextlib
import errno
import os
import random
import signal
import socket
import subprocess
import sys
import time
Expand All @@ -16,14 +20,34 @@
# does dev_appserver.py ever live anywhere but /usr/local/bin?
proc = subprocess.Popen([sys.executable,
"/usr/local/bin/dev_appserver.py",
os.path.dirname(__file__),
"--port=%d" % port
os.path.dirname(os.path.abspath(__file__)),
"--port=%d" % port,
"--skip_sdk_update_check",
],
cwd=tornado_root)
time.sleep(3)
try:
for i in xrange(50):
with contextlib.closing(socket.socket()) as sock:
err = sock.connect_ex(('localhost', port))
if err == 0:
break
elif err != errno.ECONNREFUSED:
raise Exception("Got unexpected socket error %d" % err)
time.sleep(0.1)
else:
raise Exception("Server didn't start listening")

resp = urllib2.urlopen("http://localhost:%d/" % port)
print resp.read()
finally:
os.kill(proc.pid, signal.SIGTERM)
proc.wait()
# dev_appserver sometimes ignores SIGTERM (especially on 2.5),
# so try a few times to kill it.
for sig in [signal.SIGTERM, signal.SIGTERM, signal.SIGKILL]:
os.kill(proc.pid, sig)
res = os.waitpid(proc.pid, os.WNOHANG)
if res != (0,0):
break
time.sleep(0.1)
else:
os.waitpid(proc.pid, 0)
4 changes: 4 additions & 0 deletions maint/appengine/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Dummy setup file to make tox happy. In the appengine world things aren't
# installed through setup.py
import distutils.core
distutils.core.setup()
19 changes: 19 additions & 0 deletions maint/appengine/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# App Engine tests require the SDK to be installed separately.
# Version 1.6.1 or newer is required (older versions don't work when
# python is run from a virtualenv)
#
# These are currently excluded from the main tox.ini because their
# logs are spammy and they're a little flaky.
[tox]
envlist = py25-appengine, py27-appengine

[testenv]
changedir = {toxworkdir}

[testenv:py25-appengine]
basepython = python2.5
commands = python {toxinidir}/py25/runtests.py {posargs:}

[testenv:py27-appengine]
basepython = python2.7
commands = python {toxinidir}/py27/runtests.py {posargs:}
23 changes: 23 additions & 0 deletions maint/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Frozen pip requirements for tools used in the development of tornado

# Tornado's optional dependencies
MySQL-python==1.2.3
Twisted==12.1.0
pycurl==7.19.0

# Other useful tools
Sphinx==1.1.3
autopep8==0.6.5
coverage==3.5.2
pep8==1.2
pyflakes==0.5.0
tox==1.4
virtualenv==1.7.1.2

# Indirect dependencies
Jinja2==2.6
Pygments==1.5
docutils==0.9
py==1.4.9
wsgiref==0.1.2
zope.interface==4.0.1
Empty file.
Loading

0 comments on commit 72ce4aa

Please sign in to comment.