When forking multiple processes, properly initialize the random seed
Avoid seeding the random module with the same value in all processes.
If available, use the same method used by random.py, otherwise
generate a seed using the current time in milliseconds and the pid.
Joe Bowman [Tue, 31 Aug 2010 15:38:06 +0000 (11:38 -0400)]
auth.py updates for OAuth 1.0a and 2.0.
OAuthMixin now supports both 1.0a and 1.0 (defaults to 1.0a). TwitterMixin
and GoogleMixin now use 1.0a, FriendfeedMixin remains at 1.0. This adds
support for the callback_uri parameter to TwitterMixin.
New classes OAuth2Mixin and FacebookGraphMixin are introduced for the new
Facebook APIs.
Backwards compatibility notes:
Pending authorizations begun prior to this change will not be able to
be completed after it (tokens issued under prior versions of this code
will still work; this warning applies only to users who have started
but not yet completed their initial authorizations).
If you have used OAuthMixin directly (not one of the subclasses in this
module) to access a service that does not support OAuth 1.0a, set
_OAUTH_VERSION = "1.0" in your subclass.
Ben Darnell [Wed, 1 Sep 2010 22:16:57 +0000 (15:16 -0700)]
Remove __del__ method from HTTPResponse. Closing cStringIO objects isn't
really necessary, and the presence of a __del__ method prevents python's
GC from breaking cyclical references (which happen on errors as HTTPError
and HTTPResponse refer to each other).
Ben Darnell [Mon, 16 Aug 2010 01:04:34 +0000 (18:04 -0700)]
Initialize member variables in AsyncTestCase.__init__ instead of setUp
to avoid masking the real error in _stack_context() if run() throws an
exception.
Ben Darnell [Mon, 9 Aug 2010 21:33:32 +0000 (14:33 -0700)]
Be less picky about line endings in headers in httpclient.
HTTP requires that lines end with \r\n, but some buggy servers (including
news.ycombinator.com) just use \n. Libcurl tolerates this and sends the
line as-is to the header callback, so we need to be prepared to handle
either form.
Ben Darnell [Mon, 9 Aug 2010 21:01:48 +0000 (14:01 -0700)]
The periodic call to multi_socket_all needs to be followed by
_finish_pending_request or else those requests won't be finished until
after the next one is started.
Ben Darnell [Thu, 5 Aug 2010 00:30:20 +0000 (17:30 -0700)]
Add a brute-force workaround for the class of libcurl bugs that cause
file descriptors or timeouts to get silently dropped. (the old
fdset/perform implementation of AsycnHTTPClient had a similar workaround).
Ben Darnell [Fri, 30 Jul 2010 02:08:30 +0000 (19:08 -0700)]
Fix a StackContext-related bug that was causing exceptions in callbacks
to result in timeouts instead of making wait() re-throw the exception.
Add a test to verify that this works.
Ben Darnell [Mon, 26 Jul 2010 19:04:00 +0000 (12:04 -0700)]
Add an initialize() method to RequestHandler for use by subclasses.
This is simpler than overriding __init__ since it doesn't require
knowledge of the application and request arguments that must be
passed through to the superclass's __init__.
Ben Darnell [Fri, 23 Jul 2010 19:35:08 +0000 (12:35 -0700)]
Introduce StackContext, a way to automatically manage exception
handling and other stack-related state for asynchronous callbacks.
This means that it is no longer necessary to wrap everything
in RequestHandler.async_callback.
Ben Darnell [Thu, 22 Jul 2010 21:29:07 +0000 (14:29 -0700)]
Remove websocket.py. The websocket protocol has changed in
incompatible ways (and is still not yet final), so the version
implemented in this module is not compatible with current
browsers. This module may be reintroduced in the future when
we have an implementation of the new protocol.
Ben Darnell [Tue, 20 Jul 2010 02:39:42 +0000 (19:39 -0700)]
When no json library is found, don't throw an exception unless
json functionality is used, to make the simplejson dependency optional
for python 2.5 users.
Ben Darnell [Wed, 14 Jul 2010 23:31:22 +0000 (16:31 -0700)]
Better timeout handling in AsyncHTTPClient2. Tornado and libcurl may
use different clock functions, which can cause timeouts to be delayed
(in some cases until the next fetch is started). This change
resynchronizes the schedule after each timeout call.
Ben Darnell [Sat, 10 Jul 2010 01:15:12 +0000 (18:15 -0700)]
In AsyncHTTPClient2, disable IPv6 for versions of libcurl with the
socket-reopening bug (i.e. <= 7.21.0). (this can be overridden if needed
with a prepare_curl_callback)
Ben Darnell [Fri, 9 Jul 2010 20:07:43 +0000 (13:07 -0700)]
Unquote percent escapes in captured groups in the path component of the URI,
to be more consistent with our handling of query parameters.
This change is slightly backwards-incompatible: applications that have
already added an unquote() call on arguments to RequestHandler.get/post
will need to remove them.
URI spec requires that '/' and '%2F' be distinguishable, so it's incorrect
to escape at this level. The next commit will instead unquote captured
groups before passing them to get()/post() in web.py
Ben Darnell [Fri, 9 Jul 2010 01:27:43 +0000 (18:27 -0700)]
Parse percent escapes in the path component of the uri, to be more
consistent with our handling of query parameters (especially important
when capturing groups are used in the URLSpec regex).
This change is slightly backwards-incompatible: applications that have
already added an unquote() call on arguments to RequestHandler.get/post
or use percent escapes in URLSpec patterns will need to remove them.
Ben Darnell [Sat, 26 Jun 2010 23:00:26 +0000 (16:00 -0700)]
Update the set of active file descriptors immediately after calling perform
instead of after running user callbacks, since those callbacks might have
started using file descriptors that were closed by curl in perform().
Ben Darnell [Fri, 18 Jun 2010 22:59:19 +0000 (15:59 -0700)]
Close wsgi responses correctly - the close method, if present, will
be on the result of self.wsgi_application() and not on the list
of output we're building up.
Ben Darnell [Thu, 10 Jun 2010 21:49:57 +0000 (14:49 -0700)]
In the libcurl file descriptor limit hack, log to both stderr and
logging.error since they may got to different places and one may be
more visible than the other.