Antoine Pitrou [Tue, 17 Oct 2017 16:29:47 +0000 (18:29 +0200)]
Remove SSL hack
All recent Python versions (including recent Python 2.7 updates)
set SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER on OpenSSL sockets, so
we needn't freeze the write buffer anymore.
Correctly clear and create a new ioloop during autoreload (#2137)
* Correctly clear and create a new ioloop during autoreload
After the removal of the deprecated io_loop arguments from all functions,
the autoreload module stopped working as the wait function's usage was
missed in the refactor. This resulted in the start function receiving an
IOLoop object as its only argument which it then used as the check_time
argument resulting in errors further down the line when the check_time
is expected to be an int.
* Use the ioloop's add_callback function to start the ioloop on wait
There's no need to stop and clear the loop here, just add start as
a callback and start up the ioloop.
Fitz Elliott [Thu, 10 Aug 2017 15:10:00 +0000 (11:10 -0400)]
Remove headers from HTTPServerRequest repr
* In tornadoweb/tornado#1112 it was decided to stop including headers
in the request repr, since they are needlessly verbose and risk
leaking user secrets into the application log.
Pierce Lopez [Mon, 5 Jun 2017 04:48:45 +0000 (00:48 -0400)]
http1connection: add "Connection: close" header if appropriate
When HTTP1Connection acts as the server, it closes the connection
after writing the response if the client includes the
"Connection: close" header in the request, or if the `no_keep_alive`
option is set to True in the constructor.
According to https://tools.ietf.org/html/rfc7230#section-6.6
> The server SHOULD send a "close" connection option in its final
response on that connection.
It was possible for an Application to set the Connection header
appropriately. But it is very helpful for tornado to take care of
this automatically, particularly if "close" was specified in a
request header.
Ben Darnell [Sat, 3 Jun 2017 20:08:44 +0000 (16:08 -0400)]
ioloop: Make asyncio the default when available
In addition to changing the configurable default, add a special case
in IOLoop.current() so that the current IOLoop will be backed by
the main asyncio event loop.
Ben Darnell [Mon, 29 May 2017 00:10:01 +0000 (20:10 -0400)]
tcpclient,netutil: Set FD_CLOEXEC on all sockets created by Tornado
PR #1984 was based on the mistaken belief that we were already
doing this (and in python 3.4+, it's true, thanks to PEP 446). This
fixes a regression introduced in Tornado 4.5 in which autoreload would
leak file descriptors and leave client connections hanging.
Ben Darnell [Sun, 28 May 2017 14:44:55 +0000 (10:44 -0400)]
ioloop: Redefine instance() in terms of current()
This aligns us more closely with asyncio, which only has a single
get_event_loop() function. Most uses of instance() are simply a
holdover from before current() was introduced and are not actually
relying on its slightly different behavior, so we redefine it (and the
related methods install(), initialized(), and clear_instance()) in
terms of current().
Ben Darnell [Mon, 22 May 2017 03:57:46 +0000 (23:57 -0400)]
all: Remove deprecated io_loop arguments
IOLoop.current() is now used in all cases; it is no longer possible to
pass IOLoops around and use them directly. This occasionally requires
awkward workarounds with IOLoop.run_sync, but mainly in test code
(and the synchronous HTTPClient).
Ben Darnell [Sat, 20 May 2017 16:09:58 +0000 (12:09 -0400)]
websocket: Don't swallow exceptions in _write_frame
Swallowing the exception violated the method's interface (by returning
None instead of a Future), and differs from stream-closed behavior in
other contexts in Tornado.
Antoine Pitrou [Thu, 27 Apr 2017 14:29:10 +0000 (16:29 +0200)]
Avoid IOStream.close(exc_info=True)
close(exc_info=True) calls sys.exc_info() to get the "current" exception.
Unfortunately, on Python 2 this is the last raised exception even if it
was caught and silenced (by contrast with Python 3, which has lexically
nested exceptions). This could set ``IOStream.error`` and therefore
``TCPClient.connect``'s raised exception to the wrong error.
Fix by passing the explicit error instance instead.
Fix CurlAsyncHTTPClient cause memory leak with `force_instance=True`
The CurlAsyncHTTPClient will cause memory leak when set `force_instance=True`,
because the `self._multi` and `self._force_timeout_callback` hold some methods
that belong the instance of `CurlAsyncHTTPClient`, it will cause circular reference.
Ben Darnell [Thu, 20 Apr 2017 01:38:57 +0000 (21:38 -0400)]
log: Fix color logging detection
The previous logic would fail whenever curses is missing (which is
always true on windows, and is occasionally true on other platforms)
and colorama is installed but not initialized in this process (this is
a common occurrence for users of jupyter and ipython on windows).