Ben Darnell [Sat, 21 Jun 2014 17:50:56 +0000 (13:50 -0400)]
Drop support for the draft76 version of WebSockets.
Browsers that only support draft76 are now less common than those
that do not support websockets at all, so applications should
use their non-websocket workarounds for these browsers.
Ben Darnell [Thu, 19 Jun 2014 13:28:45 +0000 (09:28 -0400)]
Add new exception tornado.web.Finish to quietly end a request.
This allows error pages to be generated inline with the main code
instead of in write_error and is friendlier to generating error pages
from library code.
Ben Darnell [Wed, 18 Jun 2014 14:29:28 +0000 (10:29 -0400)]
Introduce IOLoop.call_later and call_at.
call_later is a less-verbose alternative to add_timeout with a
timedelta; call_at exists for symmetry. Both are named after
methods on the asyncio event loop, although there are small
variations (we support both args and kwargs while asyncio only supports
args; we use remove_timeout(handle) instead of handle.cancel()).
Ben Darnell [Mon, 16 Jun 2014 03:35:02 +0000 (23:35 -0400)]
Relax restrictions on HTTP methods in WebSocketHandler.
Methods like set_status are now disallowed once the websocket handshake
has begun, but may be used before then. This applies to application
overrides of prepare() and to WebSocketHandler.get's internal error
handling.
drewbrew [Tue, 3 Jun 2014 18:22:08 +0000 (13:22 -0500)]
ioloop.py: use itertools.count() as tiebreaker to preserve FIFO in case of tie
Current implementation does not function as a FIFO. When adding multiple
timeouts with the same deadline, order is currently consistently mangled in the
event of a garbage collect.
As suggested by Ben Darnell at
https://groups.google.com/forum/#!topic/python-tornado/w8aKm6ZabUQ/discussion,
we need to add a sequence number to the Timeout class to serve as tiebreaker.
This code uses the model suggested by
https://docs.python.org/2/library/heapq.html#priority-queue-implementation-notes,
which uses itertools.count() to serve as our counter.
Ben Darnell [Sun, 25 May 2014 16:50:51 +0000 (12:50 -0400)]
Stream large response bodies from StaticFileHandler.
The get_content interface is still synchronous so it's not a complete
solution, but this will keep the server from buffering the whole file in
memory while writing it out to the client.
Return Futures from the wsgi interface, allowing @gen.coroutine to be
used there in limited circumstances.
Ben Darnell [Sun, 25 May 2014 15:39:12 +0000 (11:39 -0400)]
Remove HTTP method check from HTTPServerRequest._parse_body.
The semantics of a body are not well-defined for some methods,
but if a client sends a body with the correct content-type,
we might as well parse it no matter what the method.
Ben Darnell [Mon, 19 May 2014 03:19:41 +0000 (23:19 -0400)]
Make gen.Task a function returning a Future instead of a YieldPoint subclass.
This improves performance of applications that mix Tasks and Futures
by only entering a stack context for the duration of the Tasks. It
also fixes an obscure regression (#1058). This might get reverted before
the final release if any backwards-compatibility issues turn up, but
since the status quo also had a regression it's worth a try.
Ben Darnell [Mon, 19 May 2014 01:57:27 +0000 (21:57 -0400)]
Remove test_websocket_network_timeout.
It wasn't testing what it appeared to be (it was hitting exactly the
same code paths as test_websocket_network_fail on posix, but was failing
on windows).
Ben Darnell [Mon, 19 May 2014 00:20:29 +0000 (20:20 -0400)]
Raise StreamClosedError instead of IOError for ECONNRESET.
This allows application code to only catch one kind of exception
(an ECONNRESET exception is raised from
tornado.test.httpserver_test.KeepAliveTest.test_pipeline_cancel
on linux but not on mac)
Ben Darnell [Sat, 17 May 2014 14:56:35 +0000 (10:56 -0400)]
Fix Tornado on Google App Engine.
Imports of tornado.ioloop have crept into more places, so the old
app engine policy of never importing these modules doesn't work.
Instead, we add guards around imports of unavailable modules
(fcntl, ssl, multiprocessing) so that everything is at least importable.
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).