Ben Darnell [Sat, 8 Dec 2012 23:25:11 +0000 (18:25 -0500)]
add_callback now takes *args, **kwargs.
This reduces the need for functools.partial or lambda wrappers, and
works better with stack_context in some cases since binding the
arguments within IOLoop lets it see whether the function is already
wrapped.
Ben Darnell [Fri, 7 Dec 2012 19:19:48 +0000 (14:19 -0500)]
Catch all exceptions, not just {OS,IO}Error in IOLoop.remove_handler.
Attempting to remove a non-existent fd raises IOError on epoll
but KeyError on kqueue; this change swallows any exeption to make
both platforms consistent.
Ben Darnell [Sun, 2 Dec 2012 17:33:51 +0000 (12:33 -0500)]
Return a Vary: Accept-Encoding header whenever gzip is enabled.
This is one of two problems found with redbot. The other,
that etags should change when content-encoding is used, is trickier to
fix and seems to be less problematic.
Ben Darnell [Sat, 17 Nov 2012 21:35:42 +0000 (16:35 -0500)]
Fix a memory leak in stack_context.
The old_contexts reference in StackContexts could maintain a chain of
old irrelevant contexts, so clear it once it's no longer needed.
This was mainly a problem in gen.engine, where additional contexts
would accumulate in memory (but not on the stack) for each asynchronous
operation.
Also clear the deactivate_stack_context in gen.Runner to allow
the StackContext to be garbage-collected sooner.
Ben Darnell [Mon, 19 Nov 2012 02:35:36 +0000 (21:35 -0500)]
Remove redundant logging of read errors in IOStream.
The logging in read_from_fd is generally redundant with logging at
higher levels - the error would be logged again in _handle_read,
or propagated from _try_inline_read.
Ben Darnell [Sat, 17 Nov 2012 21:35:42 +0000 (16:35 -0500)]
Fix a memory leak in stack_context.
The old_contexts reference in StackContexts could maintain a chain of
old irrelevant contexts, so clear it once it's no longer needed.
This was mainly a problem in gen.engine, where additional contexts
would accumulate in memory (but not on the stack) for each asynchronous
operation.
Also clear the deactivate_stack_context in gen.Runner to allow
the StackContext to be garbage-collected sooner.
Ben Darnell [Tue, 30 Oct 2012 05:33:54 +0000 (22:33 -0700)]
AsyncHTTPTestCase no longer closes AsyncHTTPClients on the global IOLoop.
Code that uses the global IOLoop may retain a global reference to
an AsyncHTTPClient as well, which would become inoperable after a test
had closed it.
Peter Sobot [Tue, 23 Oct 2012 18:33:17 +0000 (15:33 -0300)]
Added period check in PeriodicCallback
If a user currently passes in 0ms (hopefully by accident) as the
callback time for a periodic callback, Tornado consumes a huge amount
of CPU and never calls the function.
Ben Darnell [Sun, 7 Oct 2012 23:59:36 +0000 (16:59 -0700)]
Fix TwistedIOLoop on epoll.
Twisted's removeAll doesn't like it if a socket is closed without being
unregistered. EPoll generates events slightly differently so be more
careful about doubled connectionLost events.
Ben Darnell [Thu, 4 Oct 2012 05:36:46 +0000 (22:36 -0700)]
Reduce log spam from closed client connections.
Added a bunch of tests for keepalive functionality and fixed two cases
where we'd log an exception when the client was gone. ECONNRESET
errors in IOStream reads now just close the connection instead of
logging an error (the exception information is still available on
stream.error in the close callback for apps that want it).
HTTPConnection now also checks for a closed connection and cleans up
instead of logging an error.
IOStream now raises a new exception class StreamClosedError instead of
IOError.
Ben Darnell [Mon, 1 Oct 2012 06:57:49 +0000 (23:57 -0700)]
Add time_func parameter to IOLoop, and make it possible to use time.monotonic.
This means that calls to IOLoop.add_timeout that pass a number must be
updated to use IOLoop.time instead of time.time.
There are still some places where we use time.time in the code, but they
are either places where wall time is desired, or non-critical deltas (e.g.
printing elapsed time at the end of a request).
Thanks to apenwarr and mgenti for pull requests and discussion relating to
this change. (#558 and #583)
Ben Darnell [Mon, 1 Oct 2012 05:19:59 +0000 (22:19 -0700)]
Extract configure logic from AsyncHTTPClient to a base class.
IOLoop now extends this base class as well, although no other
implementations are provided yet. This does not include the
pseudo-singleton magic from AsyncHTTPClient.