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).
Ben Darnell [Sun, 2 Apr 2017 14:51:41 +0000 (10:51 -0400)]
tcpclient_test: Attempt to deflake on windows
It appears that on windows the client connect call can sometimes
succeed before the server has processed the request, so introduce
additional synchronization.
Antoine Pitrou [Mon, 14 Nov 2016 18:38:25 +0000 (19:38 +0100)]
Fix IOStream.write() to never orphan Future
The current behaviour is error-prone and makes it difficult to use the
Future-returning variant of IOStream.write(). This change makes sure
the returned Future is triggered as soon as the corresponding write
is issued.
Ben Darnell [Sun, 26 Mar 2017 15:12:37 +0000 (11:12 -0400)]
websocket: Avoid calling convert_yielded twice on the same object
This is not allowed for native coroutines, although for reasons I
can't put my finger on it only fails intermittently (in the one test
we have that uses this with native coroutines).
Ben Darnell [Sat, 25 Mar 2017 18:00:26 +0000 (14:00 -0400)]
autoreload: Don't close the IOLoop on reload
This was a last-ditch effort to close file descriptors that were not
marked as CLOEXEC. However, it was never complete (it didn't touch
file descriptors that were not registered on the IOLoop), and it can't
work with asyncio (which does not allow closing the IOLoop without
stopping it and unwinding the stack first). Since Tornado (and
hopefully all major libraries using the IOLoop) is careful about
setting CLOEXEC when needed, just get rid of the close.