Stefan Tjarks [Fri, 16 May 2014 23:03:01 +0000 (16:03 -0700)]
Extended gen_test decorator to pass args and kwargs.
A use case might be a decorated test class that passes arguments to each class method, like mock.patch for instance.
Ben Darnell [Mon, 12 May 2014 03:43:55 +0000 (23:43 -0400)]
Decouple read_from_buffer's search for the endpoint from consuming the data.
This lets us call find_read_pos from read_to_buffer_loop, avoiding some
unnecessary reads (e.g. it previously took a minimum of two recv calls
to serve an http request, but now we can do it in one).
Ben Darnell [Mon, 12 May 2014 00:23:33 +0000 (20:23 -0400)]
IOStream: do not listen for close events if there is no close_callback.
HTTP1Connection now only registers its close callback when it is done
reading. This improves performance for synchronous handlers, which no
longer interact with the IOLoop as often.
Ben Darnell [Sun, 11 May 2014 22:49:40 +0000 (18:49 -0400)]
Add gen.moment, a yieldable object that resumes after one IOLoop iteration.
Use this between requests in HTTP1ServerConnection to keep one connection
from monopolizing the IOLoop when there are pipelined (or just fast) requests
available. This was causing increased variance in benchmarks using "ab -k"
(it also increased throughput, for reasons that are not yet clear, so this
change reduces observed speed in these benchmarks).
Ben Darnell [Sat, 10 May 2014 17:27:46 +0000 (13:27 -0400)]
Improve performance by using Future interface when writing HTTP responses.
Previously, we passed a callback to IOStream.write() and also checked
IOStream.writing() to see if the write completed synchronously (which is
the common case). If it did, we would complete the request immediately
but the write callback would remain on the IOLoop until its next iteration,
keeping the request state from being garbage collected.
In benchmarks, this would manifest as as something like a memory leak,
since benchmarks often handle many requests in one IOLoop iteration.
This slowed things down (by about 10% in my benchmarks) by increasing
pressure on the garbage collector.
Ben Darnell [Mon, 5 May 2014 02:59:12 +0000 (22:59 -0400)]
Add a v2 secure cookie format.
This format fixes some weaknesses in the original format that would allow
characters to be shifted from the "value" field to the "name" or "timestamp"
fields. It also upgrades the signature from HMAC-SHA1 to HMAC-SHA256,
adds an explicit version field, and adds an as-yet-unused field to
support key rotation in the future.
moijes12 [Sun, 4 May 2014 18:22:05 +0000 (23:52 +0530)]
Changed tornado/simple_httpclient.py to raise the error instead of
storing the error message and then raising an HTTPError.
Changed the websocket tests for network_fail and network timeout to
expect an IOError instead of an HTTPError.
Ben Darnell [Sat, 26 Apr 2014 18:26:41 +0000 (14:26 -0400)]
Add on_close to HTTPServerConnectionDelegate.
Add close_all_connections method to HTTPServer for testing cleanup.
On Python versions before 3.4, the GC has problems with generators,
so the previous approach of closing all the file descriptors and
leave the rest to the GC no longer works. (Only Python 3.3 prints
the uncollectable garbage warnings, but the problem is present
in earlier versions).
Ben Darnell [Mon, 21 Apr 2014 04:26:40 +0000 (00:26 -0400)]
Help out the CPython GC by clearing some references in IOLoop.close.
This prevents some of the ResourceWarnings from the test suite on python
3.3 (older versions didn't report the leaks; newer versions are better
at freeing generators). Since this is in IOLoop.close, it mainly
affects tests.
Ben Darnell [Sun, 20 Apr 2014 21:01:43 +0000 (17:01 -0400)]
Move address manipulation from HTTP1Connection to HTTPServer.
The connection now contains only an opaque 'origin' object to which
the caller can attach address info. This object can also be mutated
as in HTTPServer's xheader support.
Ben Darnell [Sun, 20 Apr 2014 00:13:40 +0000 (20:13 -0400)]
Timeout micro-optimizations.
Use the (C) timedelta.total_seconds function when available. But it's
still a bit faster to use numeric timeouts instead of back-and-forth
through timedelta, so do that instead in http1connection.
Ben Darnell [Sat, 19 Apr 2014 02:16:55 +0000 (22:16 -0400)]
Read less aggressively in IOStream.
Previously, we would drain the socket buffer into the IOStream read buffer
before trying to satisfy application requests. This would result in
unnecessary memory use, and on a fast network reads could fail because the
buffer would fill up. Now we stop reading when we can satisfy the current
request (at least for read_bytes and read_until with max_bytes; unbounded
read_until still reads aggressively).
This commit includes a change to IOStream close_callback semantics. Since
the only way to reliably detect a closed connection (across all IOLoop
implementations) is to read past the end of the stream, the IOStream will
not detect a closed connection while there is some buffered data that could
satisfy a future read.
Ben Darnell [Sat, 29 Mar 2014 15:01:14 +0000 (15:01 +0000)]
Add body_producer argument to httpclient.HTTPRequest.
This allows for sending non-contiguous or asynchronously-produced
request bodies, including chunked encoding when the content-length
is not known in advance.
Ben Darnell [Sat, 29 Mar 2014 14:03:15 +0000 (14:03 +0000)]
Add option to disable the Resolver tests with an environment variable.
The resolver tests depend on external network resources; the twisted
resolver will time out when the network is unvailable instead of
returning an immediate failure like the other implementations.