Ben Darnell [Sat, 22 Jun 2019 16:50:07 +0000 (12:50 -0400)]
test: Skip test_source_port_fail when running as root
Root is always allowed to bind to low port numbers, so we can't
simulate failure in this case. This is the last remaining failure when
running tests in docker.
Ben Darnell [Sat, 22 Jun 2019 15:38:50 +0000 (11:38 -0400)]
*: Modernize IO error handling
Where possible, replace use of errno with the exception hierarchy
available since python 3.3. Remove explicit handling of EINTR which
has been automatic since python 3.5
Robin Roth [Mon, 17 Jun 2019 00:21:13 +0000 (02:21 +0200)]
mypy: Enable no_implicit_optional
"Implicit-optional" mode is on by default, but that default is intended to change in the indefinite future (python/peps#689, python/typing#275). Go ahead and change to the future explicit use of Optional.
Replace `_CRLF_RE.split(headers)` with a simple `headers.split('\n')` with an additional check for `'\r'` in each line.
Add benchmark to measure performance impact of the change.
The benchmark results are as follows:
* split only: ~3x faster on CPython, 14-18x faster on PyPy
* full headers parse: ~1.3x faster on CPython, ~3-4.5x faster on PyPy
Ben Darnell [Sat, 23 Mar 2019 15:11:18 +0000 (11:11 -0400)]
httpclient: HTTPResponse.body returns empty string instead of raising
In tornado 5, HTTPResponse.body would return None if there was no body
buffer (which included errors like timeouts and socket errors, but not
HTTP errors like 404). In tornado 6 this was changed to never return
None (to make it easier to work with type annotations) and raise an
error instead. This turned out to be disruptive, so change it back to
returning a value without raising (but now it's an empty byte string
instead of None).
Pierce Lopez [Fri, 1 Mar 2019 20:22:14 +0000 (15:22 -0500)]
travis-ci tests: always use dist xenial
Travis-CI Trusty Container-based environment was available
between July, 2017 and December, 2018.
https://docs.travis-ci.com/user/reference/overview/#deprecated-virtualization-environments
Ben Darnell [Fri, 1 Mar 2019 20:03:31 +0000 (15:03 -0500)]
Fix importability on python 3.5.2
The "provisional" typing module in 3.5.2 is kind of broken/incomplete
so we need to use more forward references to avoid confusing it. The
significance of this version in particular is that it was the one
included in ubuntu 16.04.
Ben Darnell [Sun, 3 Feb 2019 23:01:53 +0000 (18:01 -0500)]
ioloop: Micro-optimize IOLoop.add_future
Asyncio Futures always schedule their callbacks on a future iteration
of the IOLoop, so routing the callbacks through IOLoop.add_callback
again was redundant and causing unnecessary delays in callback
execution.
Ben Darnell [Tue, 1 Jan 2019 17:50:07 +0000 (12:50 -0500)]
http1connection: Fix a bug with redirects and chunked requests
After a redirect, the chunked-encoding header is already set and would
not be detected correctly. This affects empty bodies with
allow_nonstandard_methods and any use of body_producer.
Ben Darnell [Sun, 30 Dec 2018 17:10:20 +0000 (12:10 -0500)]
websocket: Change some Future type annotations to Awaitables
This conforms with usage elsewhere, that methods returning None use
Futures (self-starting in case the result is not awaited) and others
use Awaitable (reserving the option to use more efficient native
coroutines).
Ben Darnell [Sun, 30 Dec 2018 00:57:39 +0000 (19:57 -0500)]
docs: Use python 3.7 via conda for readthedocs builds
The typing module in python 3.5 has problems with some type
annotations so we need to build with 3.7. RTD doesn't yet support py37
natively but we can get it with conda following an example at
https://github.com/rtfd/readthedocs-docker-images/pull/73
Ben Darnell [Mon, 24 Dec 2018 16:57:33 +0000 (11:57 -0500)]
websocket: Make WSH.get a coroutine
This is necessary to convert accept_connection to native coroutines -
the handshake no longer completes within a single IOLoop iteration
with this change due to coroutine scheduling.
This has the side effect of keeping the HTTP1Connection open for the
lifetime of the websocket connection. That's not great for memory, but
might help streamline close handling. Either way, it'll be refactored
in a future change.