Codeb Fan [Wed, 21 Aug 2013 06:56:29 +0000 (14:56 +0800)]
Add timeout for requests in SimpleAsyncHTTPClient's queue.
The connect_timeout and request_timeout in HTTPRequest only matter when
the _HTTPConnection get created. In heavy-loadded situation requests in
SimpleAsyncHTTPClient may have already timeouted before they pop out
from queue and get actual processed. This commit adds an timeout
callback for every request appended to SimpleAsyncHTTPClient's request
queue that cannot be processed immediately.
Ben Darnell [Mon, 19 Aug 2013 03:54:59 +0000 (23:54 -0400)]
In add_callback, hold the lock while writing to the waker pipe.
This protects against a shutdown race condition seen occasionally in
the ThreadedResolver unittests. This slightly increases contention
on the callback lock in multi-threaded scenarios, but the cost is
limited by the fact that we only write to the pipe once per IOLoop
iteration.
Ben Darnell [Tue, 13 Aug 2013 03:34:00 +0000 (23:34 -0400)]
Update ca-certificates.crt to the current Mozilla version.
This file was generated by downloading
https://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1
in a web browser to avoid the chicken-and-egg problem with mk-ca-bundle's
built-in downloading, and then running "mk-ca-bundle.pl -n".
Note that we were not affected by the recently-fixed curl bug
(https://github.com/bagder/curl/commit/51f0b798fa), but only because
it had been so long since we had updated this file.
Ben Dyer [Fri, 12 Jul 2013 06:35:09 +0000 (16:35 +1000)]
Correctly handle EAGAIN when writing to PipeIOStreams
BaseIOStream._handle_write needs to catch IOError and OSError as
well as socket.error in order to handle EAGAIN when writing to a
PipeIOStream (which doesn't appear to raise socket.error when the
buffer is full).
This also provides consistency with the exceptions caught by
BaseIOStream._read_to_buffer.
Ben Darnell [Sun, 7 Jul 2013 17:30:00 +0000 (13:30 -0400)]
Unify lists of errnos used in IOStream.
We generally want to treat aborted connections the same regardless of the
specific errno, but some calls caught ECONNRESET and ECONNABORTED
while others only caught ECONNRESET. Reported in #828.
Ben Darnell [Wed, 12 Jun 2013 03:32:40 +0000 (23:32 -0400)]
Set CLOEXEC on subprocess pipe endpoints so they are not inherited by the child.
This is what the subprocess module does when it creates pipes, and is
necessary so that a close of the writing side of the stdin pipe will
be recognized by the child process.
Ben Darnell [Thu, 6 Jun 2013 01:43:16 +0000 (21:43 -0400)]
Catch StreamClosedErrors in WebSocketHandler and abort.
When the stream is closed with buffered data, the close callback won't
be run until all buffered data is consumed, but any attempt to write
to the stream will fail, as will reading past the end of the buffer.
This requires a try/except around each read or write, analogous to the
one introduced in HTTPServer in commit 3258726f.
Ben Darnell [Sat, 1 Jun 2013 21:30:33 +0000 (17:30 -0400)]
Reuse a single ThreadPoolExecutor for all ThreadedResolvers.
The primary motivation is that shutting down a ThreadPoolExecutor takes
100ms in the 2.x backported version of concurrent.futures. It's also
generally unnecessary to create lots of DNS resolver threads just
because multiple resolver objects are used.
Ben Darnell [Sat, 1 Jun 2013 00:45:42 +0000 (20:45 -0400)]
Make the auth*_redirect methods all return Futures.
The OAuth 1.0 authorize_redirect is asynchronous, but this is not obvious
since it doesn't take a callback and instead just calls self.finish.
This fails in coroutines because the request will be auto-finished too soon.
Add Future returns to this method, and to all the rest for consistency.
Update docs and add tests for the various styles of login handlers.
Ben Darnell [Sat, 1 Jun 2013 00:03:02 +0000 (20:03 -0400)]
Doc patch for 3.0: replace @gen.coroutine with @gen.engine.
The oauth 1.0 redirect methods are asynchronous even though they don't
take a callback, so we don't want the end of the coroutine to trigger
a call to self.finish.
Ben Darnell [Sat, 25 May 2013 19:26:37 +0000 (15:26 -0400)]
Use remove and add instead of update_handler in curl_httpclient.
Curl sometimes fails to tell us that it has closed a socket
and reopened a new one with the same file descriptor, leading
to problems in some IOLoops. This should fix the recurring problem
of update_handler errors in various less-common use cases.
Ben Darnell [Fri, 24 May 2013 04:41:23 +0000 (00:41 -0400)]
Revert change to use time.strftime (from 3.0).
time.strftime is influenced by the user's locale (if one is set with
locale.setlocale), so it's not what we want. Go back to the (slower)
email.utils functions.