Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc updates #1956

Merged
merged 7 commits into from
Feb 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ include tornado/test/static_foo.txt
include tornado/test/templates/utf8.html
include tornado/test/test.crt
include tornado/test/test.key
include LICENSE
include README.rst
include runtests.sh
14 changes: 0 additions & 14 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.doctest",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
]
Expand Down Expand Up @@ -79,19 +78,6 @@
('index', 'tornado.tex', 'Tornado Documentation', 'The Tornado Authors', 'manual', False),
]

# HACK: sphinx has limited support for substitutions with the |version|
# variable, but there doesn't appear to be any way to use this in a link
# target.
# http://stackoverflow.com/questions/1227037/substitutions-inside-links-in-rest-sphinx
# The extlink extension can be used to do link substitutions, but it requires a
# portion of the url to be literally contained in the document. Therefore,
# this link must be referenced as :current_tarball:`z`
extlinks = {
'current_tarball': (
'https://pypi.org/packages/source/t/tornado/tornado-%s.tar.g%%s' % version,
'tornado-%s.tar.g' % version),
}

intersphinx_mapping = {
'python': ('https://docs.python.org/3.5/', None),
}
Expand Down
16 changes: 11 additions & 5 deletions docs/guide/coroutines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ Python 3.5: ``async`` and ``await``

Python 3.5 introduces the ``async`` and ``await`` keywords (functions
using these keywords are also called "native coroutines"). Starting in
Tornado 4.3, you can use them in place of ``yield``-based coroutines.
Simply use ``async def foo()`` in place of a function definition with
the ``@gen.coroutine`` decorator, and ``await`` in place of yield. The
Tornado 4.3, you can use them in place of most ``yield``-based
coroutines (see the following paragraphs for limitations). Simply use
``async def foo()`` in place of a function definition with the
``@gen.coroutine`` decorator, and ``await`` in place of yield. The
rest of this document still uses the ``yield`` style for compatibility
with older versions of Python, but ``async`` and ``await`` will run
faster when they are available::
Expand All @@ -55,9 +56,14 @@ faster when they are available::
The ``await`` keyword is less versatile than the ``yield`` keyword.
For example, in a ``yield``-based coroutine you can yield a list of
``Futures``, while in a native coroutine you must wrap the list in
`tornado.gen.multi`. You can also use `tornado.gen.convert_yielded`
`tornado.gen.multi`. This also eliminates the integration with
`concurrent.futures`. You can use `tornado.gen.convert_yielded`
to convert anything that would work with ``yield`` into a form that
will work with ``await``.
will work with ``await``::

async def f():
executor = concurrent.futures.ThreadPoolExecutor()
await tornado.gen.convert_yielded(executor.submit(g))

While native coroutines are not visibly tied to a particular framework
(i.e. they do not use a decorator like `tornado.gen.coroutine` or
Expand Down
27 changes: 7 additions & 20 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ applications that require a long-lived connection to each user.
Quick links
-----------

* |Download current version|: :current_tarball:`z` (:doc:`release notes <releases>`)
* Current version: |version| (`download from PyPI <https://pypi.python.org/pypi/tornado>`_, :doc:`release notes <releases>`)
* `Source (github) <https://github.com/tornadoweb/tornado>`_
* Mailing lists: `discussion <http://groups.google.com/group/python-tornado>`_ and `announcements <http://groups.google.com/group/python-tornado-announce>`_
* `Stack Overflow <http://stackoverflow.com/questions/tagged/tornado>`_
* `Wiki <https://github.com/tornadoweb/tornado/wiki/Links>`_

.. |Download current version| replace:: Download version |version|

Hello, world
------------

Expand Down Expand Up @@ -57,27 +55,16 @@ that see this `simple chat room
Installation
------------

**Automatic installation**::
::

pip install tornado

Tornado is listed in `PyPI <http://pypi.python.org/pypi/tornado>`_ 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 :current_tarball:`z`:

.. parsed-literal::

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

The Tornado source code is `hosted on GitHub
<https://github.com/tornadoweb/tornado>`_.
can be installed with ``pip``. 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 or clone the `git repository
<https://github.com/tornadoweb/tornado>`_ as well.

**Prerequisites**: Tornado 4.3 runs on Python 2.7, and 3.3+
For Python 2, version 2.7.9 or newer is *strongly*
Expand Down
3 changes: 2 additions & 1 deletion maint/test/cython/tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
# This currently segfaults on pypy.
envlist = py27,py33,py34,py35
envlist = py27,py33,py34,py35,py36

[testenv]
deps =
Expand All @@ -16,3 +16,4 @@ basepython =
py33: python3.3
py34: python3.4
py35: python3.5
py36: python3.6
4 changes: 4 additions & 0 deletions tornado/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ def _set_returncode(self, status):
else:
assert os.WIFEXITED(status)
self.returncode = os.WEXITSTATUS(status)
# We've taken over wait() duty from the subprocess.Popen
# object. If we don't inform it of the process's return code,
# it will log a warning at destruction in python 3.6+.
self.proc.returncode = self.returncode
if self._exit_callback:
callback = self._exit_callback
self._exit_callback = None
Expand Down
8 changes: 6 additions & 2 deletions tornado/tcpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,12 @@ def _create_stream(self, max_buffer_size, af, addr, source_ip=None,
socket_obj = socket.socket(af)
if source_port_bind or source_ip_bind:
# If the user requires binding also to a specific IP/port.
socket_obj.bind((source_ip_bind, source_port_bind))
# Fail loudly if unable to use the IP/port.
try:
socket_obj.bind((source_ip_bind, source_port_bind))
except socket.error:
socket_obj.close()
# Fail loudly if unable to use the IP/port.
raise
try:
stream = IOStream(socket_obj,
io_loop=self.io_loop,
Expand Down
6 changes: 3 additions & 3 deletions tornado/test/process_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_subprocess(self):
stdin=Subprocess.STREAM,
stdout=Subprocess.STREAM, stderr=subprocess.STDOUT,
io_loop=self.io_loop)
self.addCleanup(lambda: os.kill(subproc.pid, signal.SIGTERM))
self.addCleanup(lambda: (subproc.proc.terminate(), subproc.proc.wait()))
subproc.stdout.read_until(b'>>> ', self.stop)
self.wait()
subproc.stdin.write(b"print('hello')\n")
Expand All @@ -170,7 +170,7 @@ def test_close_stdin(self):
stdin=Subprocess.STREAM,
stdout=Subprocess.STREAM, stderr=subprocess.STDOUT,
io_loop=self.io_loop)
self.addCleanup(lambda: os.kill(subproc.pid, signal.SIGTERM))
self.addCleanup(lambda: (subproc.proc.terminate(), subproc.proc.wait()))
subproc.stdout.read_until(b'>>> ', self.stop)
self.wait()
subproc.stdin.close()
Expand All @@ -186,7 +186,7 @@ def test_stderr(self):
r"import sys; sys.stderr.write('hello\n')"],
stderr=Subprocess.STREAM,
io_loop=self.io_loop)
self.addCleanup(lambda: os.kill(subproc.pid, signal.SIGTERM))
self.addCleanup(lambda: (subproc.proc.terminate(), subproc.proc.wait()))
subproc.stderr.read_until(b'\n', self.stop)
data = self.wait()
self.assertEqual(data, b'hello\n')
Expand Down
4 changes: 3 additions & 1 deletion tornado/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,9 @@ def main(**kwargs):

This test runner is essentially equivalent to `unittest.main` from
the standard library, but adds support for tornado-style option
parsing and log formatting.
parsing and log formatting. It is *not* necessary to use this
`main` function to run tests using `AsyncTestCase`; these tests
are self-contained and can run with any test runner.

The easiest way to run a test is via the command line::

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ basepython =
pypy: pypy
pypy3: pypy3
py2: python2.7
py3: python3.5
py3: python3.6

deps =
# unittest2 doesn't add anything we need on 2.7+, but we should ensure that
Expand Down