🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### Navigation - [index](# "General Index") - [modules](# "Python Module Index") | - [next](# "What鈥檚 new in Tornado 3.1.1") | - [previous](# "What鈥檚 new in Tornado 3.2.1") | - [Tornado 4.4.dev1 documentation](#) » - [Release notes](#) » # What's new in Tornado 3.2 ### Jan 14, 2014 ### Installation - Tornado now depends on the [backports.ssl_match_hostname](https://pypi.python.org/pypi/backports.ssl_match_hostname) [https://pypi.python.org/pypi/backports.ssl_match_hostname] whenrunning on Python 2. This will be installed automatically when using `pip`or `easy_install` - Tornado now includes an optional C extension module, which greatly improvesperformance of websockets. This extension will be built automaticallyif a C compiler is found at install time. ### New modules - The [`tornado.platform.asyncio`](# "tornado.platform.asyncio") module provides integration with the`asyncio` module introduced in Python 3.4 (also available for Python3.3 with `pip install asyncio`). ### [`tornado.auth`](# "tornado.auth") - Added [`GoogleOAuth2Mixin`](# "tornado.auth.GoogleOAuth2Mixin") support authentication to Google serviceswith OAuth 2 instead of OpenID and OAuth 1. - [`FacebookGraphMixin`](# "tornado.auth.FacebookGraphMixin") has been updated to use the current Facebook loginURL, which saves a redirect. ### [`tornado.concurrent`](# "tornado.concurrent") - `TracebackFuture` now accepts a `timeout` keyword argument (althoughit is still incorrect to use a non-zero timeout in non-blocking code). ### `tornado.curl_httpclient` - `tornado.curl_httpclient` now works on Python 3 with thesoon-to-be-released pycurl 7.19.3, which will officially supportPython 3 for the first time. Note that there are some unofficialPython 3 ports of pycurl (Ubuntu has included one for its pastseveral releases); these are not supported for use with Tornado. ### [`tornado.escape`](# "tornado.escape") - [`xhtml_escape`](# "tornado.escape.xhtml_escape") now escapes apostrophes as well. - [`tornado.escape.utf8`](# "tornado.escape.utf8"), [`to_unicode`](# "tornado.escape.to_unicode"), and [`native_str`](# "tornado.escape.native_str") now raise[`TypeError`](https://docs.python.org/3.4/library/exceptions.html#TypeError "(in Python v3.4)") [https://docs.python.org/3.4/library/exceptions.html#TypeError] instead of [`AssertionError`](https://docs.python.org/3.4/library/exceptions.html#AssertionError "(in Python v3.4)") [https://docs.python.org/3.4/library/exceptions.html#AssertionError] when given an invalid value. ### [`tornado.gen`](# "tornado.gen") - Coroutines may now yield dicts in addition to lists to wait formultiple tasks in parallel. - Improved performance of [`tornado.gen`](# "tornado.gen") when yielding a [`Future`](# "tornado.concurrent.Future") that isalready done. ### [`tornado.httpclient`](# "tornado.httpclient") - [`tornado.httpclient.HTTPRequest`](# "tornado.httpclient.HTTPRequest") now uses property setters so thatsetting attributes after construction applies the same conversionsas `__init__` (e.g. converting the body attribute to bytes). ### [`tornado.httpserver`](# "tornado.httpserver") - Malformed `x-www-form-urlencoded` request bodies will now log a warningand continue instead of causing the request to fail (similar to the existinghandling of malformed `multipart/form-data` bodies. This is done mainlybecause some libraries send this content type by default even when the datais not form-encoded. - Fix some error messages for unix sockets (and other non-IP sockets) ### [`tornado.ioloop`](# "tornado.ioloop") - [`IOLoop`](# "tornado.ioloop.IOLoop") now uses [`handle_callback_exception`](# "tornado.ioloop.IOLoop.handle_callback_exception") consistently forerror logging. - [`IOLoop`](# "tornado.ioloop.IOLoop") now frees callback objects earlier, reducing memory usagewhile idle. - [`IOLoop`](# "tornado.ioloop.IOLoop") will no longer call [`logging.basicConfig`](https://docs.python.org/3.4/library/logging.html#logging.basicConfig "(in Python v3.4)") [https://docs.python.org/3.4/library/logging.html#logging.basicConfig] if there is a handlerdefined for the root logger or for the `tornado` or `tornado.application`loggers (previously it only looked at the root logger). ### [`tornado.iostream`](# "tornado.iostream") - [`IOStream`](# "tornado.iostream.IOStream") now recognizes `ECONNABORTED` error codes in more places(which was mainly an issue on Windows). - [`IOStream`](# "tornado.iostream.IOStream") now frees memory earlier if a connection is closed whilethere is data in the write buffer. - [`PipeIOStream`](# "tornado.iostream.PipeIOStream") now handles `EAGAIN` error codes correctly. - [`SSLIOStream`](# "tornado.iostream.SSLIOStream") now initiates the SSL handshake automatically withoutwaiting for the application to try and read or write to the connection. - Swallow a spurious exception from `set_nodelay` when a connectionhas been reset. ### [`tornado.locale`](# "tornado.locale") - [`Locale.format_date`](# "tornado.locale.Locale.format_date") no longer forces the use of absolutedates in Russian. ### [`tornado.log`](# "tornado.log") - Fix an error from [`tornado.log.enable_pretty_logging`](# "tornado.log.enable_pretty_logging") when[`sys.stderr`](https://docs.python.org/3.4/library/sys.html#sys.stderr "(in Python v3.4)") [https://docs.python.org/3.4/library/sys.html#sys.stderr] does not have an `isatty` method. - [`tornado.log.LogFormatter`](# "tornado.log.LogFormatter") now accepts keyword arguments `fmt`and `datefmt`. ### [`tornado.netutil`](# "tornado.netutil") - [`is_valid_ip`](# "tornado.netutil.is_valid_ip") (and therefore `HTTPRequest.remote_ip`) now rejectsempty strings. - Synchronously using [`ThreadedResolver`](# "tornado.netutil.ThreadedResolver") at import time to resolvea unicode hostname no longer deadlocks. ### [`tornado.platform.twisted`](# "tornado.platform.twisted") - [`TwistedResolver`](# "tornado.platform.twisted.TwistedResolver") now has better error handling. ### [`tornado.process`](# "tornado.process") - [`Subprocess`](# "tornado.process.Subprocess") no longer leaks file descriptors if [`subprocess.Popen`](https://docs.python.org/3.4/library/subprocess.html#subprocess.Popen "(in Python v3.4)") [https://docs.python.org/3.4/library/subprocess.html#subprocess.Popen] fails. ### `tornado.simple_httpclient` - `simple_httpclient` now applies the `connect_timeout` to requeststhat are queued and have not yet started. - On Python 2.6, `simple_httpclient` now uses TLSv1 instead of SSLv3. - `simple_httpclient` now enforces the connect timeout during DNS resolution. - The embedded `ca-certificates.crt` file has been updated with the currentMozilla CA list. ### [`tornado.web`](# "tornado.web") - [`StaticFileHandler`](# "tornado.web.StaticFileHandler") no longer fails if the client requests a `Range` thatis larger than the entire file (Facebook has a crawler that does this). - [`RequestHandler.on_connection_close`](# "tornado.web.RequestHandler.on_connection_close") now works correctly on subsequentrequests of a keep-alive connection. - New application setting `default_handler_class` can be used to easilyset up custom 404 pages. - New application settings `autoreload`, `compiled_template_cache`,`static_hash_cache`, and `serve_traceback` can be used to controlindividual aspects of debug mode. - New methods [`RequestHandler.get_query_argument`](# "tornado.web.RequestHandler.get_query_argument") and[`RequestHandler.get_body_argument`](# "tornado.web.RequestHandler.get_body_argument") and new attributes`HTTPRequest.query_arguments` and `HTTPRequest.body_arguments` allow accessto arguments without intermingling those from the query string with thosefrom the request body. - [`RequestHandler.decode_argument`](# "tornado.web.RequestHandler.decode_argument") and related methods now raisean `HTTPError(400)` instead of [`UnicodeDecodeError`](https://docs.python.org/3.4/library/exceptions.html#UnicodeDecodeError "(in Python v3.4)") [https://docs.python.org/3.4/library/exceptions.html#UnicodeDecodeError] when theargument could not be decoded. - [`RequestHandler.clear_all_cookies`](# "tornado.web.RequestHandler.clear_all_cookies") now accepts `domain` and `path`arguments, just like [`clear_cookie`](# "tornado.web.RequestHandler.clear_cookie"). - It is now possible to specify handlers by name when using the [`URLSpec`](# "tornado.web.URLSpec")class. - [`Application`](# "tornado.web.Application") now accepts 4-tuples to specify the `name` parameter(which previously required constructing a [`URLSpec`](# "tornado.web.URLSpec") object instead ofa tuple). - Fixed an incorrect error message when handler methods return a valueother than None or a Future. - Exceptions will no longer be logged twice when using both `@asynchronous`and `@gen.coroutine` ### [`tornado.websocket`](# "tornado.websocket") - [`WebSocketHandler.write_message`](# "tornado.websocket.WebSocketHandler.write_message") now raises [`WebSocketClosedError`](# "tornado.websocket.WebSocketClosedError") insteadof [`AttributeError`](https://docs.python.org/3.4/library/exceptions.html#AttributeError "(in Python v3.4)") [https://docs.python.org/3.4/library/exceptions.html#AttributeError] when the connection has been closed. - [`websocket_connect`](# "tornado.websocket.websocket_connect") now accepts preconstructed `HTTPRequest` objects. - Fix a bug with [`WebSocketHandler`](# "tornado.websocket.WebSocketHandler") when used with some proxies thatunconditionally modify the `Connection` header. - [`websocket_connect`](# "tornado.websocket.websocket_connect") now returns an error immediately for refused connectionsinstead of waiting for the timeout. - [`WebSocketClientConnection`](# "tornado.websocket.WebSocketClientConnection") now has a `close` method. ### [`tornado.wsgi`](# "tornado.wsgi") - [`WSGIContainer`](# "tornado.wsgi.WSGIContainer") now calls the iterable's `close()` method even ifan error is raised, in compliance with the spec. © Copyright 2009-2016, The Tornado Authors. Created using [Sphinx](http://sphinx-doc.org/) 1.3.5.