tornado API reference
306 public APIs from tornado (tornadoweb/tornado) — 84 classes, 48 functions, 174 methods. Signatures extracted by static analysis of the actual source.
Repository: tornadoweb/tornado
| Kind | Count |
|---|---|
| Classes | 84 |
| Functions | 48 |
| Methods | 174 |
API list
class
tornado.auth.FacebookGraphMixinFacebook authentication using the new Graph API and OAuth2.
class
tornado.auth.GoogleOAuth2MixinGoogle authentication using OAuth2.
class
tornado.auth.OAuth2MixinAbstract implementation of OAuth 2.0.
method
tornado.auth.OAuth2Mixin.oauth2_request(url:str, access_token:str | None=None, post_args:dict[str, Any] | None=None, **args:Any) -> AnyFetches the given URL auth an OAuth2 access token.
class
tornado.auth.OAuthMixinAbstract implementation of OAuth 1.0 and 1.0a.
method
tornado.auth.OAuthMixin.get_authenticated_user(http_client:httpclient.AsyncHTTPClient | None=None) -> dict[str, Any]Gets the OAuth authorized user and access token.
class
tornado.auth.OpenIdMixinAbstract implementation of OpenID and Attribute Exchange.
method
tornado.auth.OpenIdMixin.get_authenticated_user(http_client:httpclient.AsyncHTTPClient | None=None) -> dict[str, Any]Fetches the authenticated user data upon redirect.
class
tornado.auth.TwitterMixinTwitter OAuth authentication.
func
tornado.autoreload.add_reload_hook(fn:Callable[[], None]) -> NoneAdd a function to be called before reloading the process.
func
tornado.autoreload.start(check_time:int=500) -> NoneBegins watching source files for changes.
func
tornado.autoreload.wait() -> NoneWait for a watched file to change, then restart the process.
func
tornado.autoreload.watch(filename:str) -> NoneAdd a file to the watch list.
func
tornado.concurrent.future_set_exception_unless_cancelled(future:'Union[futures.Future[_T], Future[_T]]', exc:BaseException) -> NoneSet the given ``exc`` as the `Future`'s exception.
func
tornado.escape.json_decode(value:str | bytes) -> AnyReturns Python objects for the given JSON string.
func
tornado.escape.json_encode(value:Any) -> strJSON-encodes the given Python object.
func
tornado.escape.recursive_unicode(obj:Any) -> AnyWalks a simple data structure, converting byte strings to unicode.
func
tornado.escape.squeeze(value:str) -> strReplace all sequences of whitespace chars with a single space.
func
tornado.escape.url_escape(value:str | bytes, plus:bool=True) -> strReturns a URL-encoded version of the given value.
func
tornado.escape.xhtml_escape(value:str | bytes) -> strEscapes a string so it is valid within HTML or XML.
func
tornado.escape.xhtml_unescape(value:str | bytes) -> strUn-escapes an XML-escaped string.
class
tornado.gen.ReturnSpecial exception to return a value from a `coroutine`.
class
tornado.gen.RunnerInternal implementation of `tornado.gen.coroutine`.
func
tornado.gen.convert_yielded(yielded:_Yieldable) -> FutureConvert a yielded object into a `.Future`.
func
tornado.gen.is_coroutine_function(func:Any) -> boolReturn whether *func* is a coroutine function, i.e.
func
tornado.gen.maybe_future(x:Any) -> FutureConverts ``x`` into a `.Future`.
func
tornado.gen.sleep(duration:float) -> 'Future[None]'Return a `.Future` that resolves after the given number of seconds.
class
tornado.http1connection.HTTP1ConnectionImplements the HTTP/1.x protocol.
method
tornado.http1connection.HTTP1Connection.detach() -> iostream.IOStreamTake control of the underlying stream.
method
tornado.http1connection.HTTP1Connection.finish() -> NoneImplements `.HTTPConnection.finish`.
method
tornado.http1connection.HTTP1Connection.read_response(delegate:httputil.HTTPMessageDelegate) -> Awaitable[bool]Read a single HTTP response.
method
tornado.http1connection.HTTP1Connection.set_body_timeout(timeout:float) -> NoneSets the body timeout for a single request.
method
tornado.http1connection.HTTP1Connection.set_max_body_size(max_body_size:int) -> NoneSets the body size limit for a single request.
method
tornado.http1connection.HTTP1Connection.write(chunk:bytes) -> 'Future[None]'Implements `.HTTPConnection.write`.
class
tornado.http1connection.HTTP1ServerConnectionAn HTTP/1.x server.
method
tornado.http1connection.HTTP1ServerConnection.close() -> NoneCloses the connection.
method
tornado.http1connection.HTTP1ServerConnection.start_serving(delegate:httputil.HTTPServerConnectionDelegate) -> NoneStarts serving requests on this connection.
func
tornado.http1connection.parse_hex_int(s:str) -> intParse a non-negative hexadecimal integer from a string.
func
tornado.http1connection.parse_int(s:str) -> intParse a non-negative integer from a string.
class
tornado.httpclient.AsyncHTTPClientAn non-blocking HTTP client.
method
tornado.httpclient.AsyncHTTPClient.configure(impl:'Union[None, str, Type[Configurable]]', **kwargs:Any) -> NoneConfigures the `AsyncHTTPClient` subclass to use.
class
tornado.httpclient.HTTPClientA blocking HTTP client.
method
tornado.httpclient.HTTPClient.close() -> NoneCloses the HTTPClient, freeing any resources used.
method
tornado.httpclient.HTTPClient.fetch(request:Union['HTTPRequest', str], **kwargs:Any) -> 'HTTPResponse'Executes a request, returning an `HTTPResponse`.
class
tornado.httpclient.HTTPClientErrorException thrown for an unsuccessful HTTP request.
class
tornado.httpclient.HTTPRequestHTTP client request object.
class
tornado.httpclient.HTTPResponseHTTP Response object.
class
tornado.httpserver.HTTPServerA non-blocking, single-threaded HTTP server.
class
tornado.httputil.HTTPConnectionApplications use this interface to write their responses.
method
tornado.httputil.HTTPConnection.finish() -> NoneIndicates that the last body data has been written.
method
tornado.httputil.HTTPConnection.write(chunk:bytes) -> Future[None]Writes a chunk of body data.
method
tornado.httputil.HTTPConnection.write_headers(start_line:RequestStartLine | ResponseStartLine, headers:HTTPHeaders, chunk:bytes | None=None) -> Future[None]Write an HTTP header block.
class
tornado.httputil.HTTPFileRepresents a file uploaded via a form.
class
tornado.httputil.HTTPHeadersA dictionary that maintains ``Http-Header-Case`` for all keys.
method
tornado.httputil.HTTPHeaders.add(name:str, value:str, *_chars_are_bytes:bool=True) -> NoneAdds a new value for the given key.
method
tornado.httputil.HTTPHeaders.get_all() -> Iterable[tuple[str, str]]Returns an iterable of all (name, value) pairs.
method
tornado.httputil.HTTPHeaders.get_list(name:str) -> list[str]Returns all values for the given header as a list.
method
tornado.httputil.HTTPHeaders.parse(headers:str, *_chars_are_bytes:bool=True) -> HTTPHeadersReturns a dictionary from HTTP header text.
method
tornado.httputil.HTTPHeaders.parse_line(line:str, *_chars_are_bytes:bool=True) -> NoneUpdates the dictionary with a single header line.
class
tornado.httputil.HTTPOutputErrorException class for errors in HTTP output.
class
tornado.httputil.HTTPServerRequestA single HTTP request.
method
tornado.httputil.HTTPServerRequest.cookies() -> dict[str, http.cookies.Morsel]A dictionary of ``http.cookies.Morsel`` objects.
method
tornado.httputil.HTTPServerRequest.full_url() -> strReconstructs the full URL for this request.
method
tornado.httputil.HTTPServerRequest.get_ssl_certificate(binary_form:bool=False) -> None | dict | bytesReturns the client's SSL certificate, if any.
class
tornado.httputil.ParseBodyConfigThis class configures the parsing of request bodies.
func
tornado.httputil.format_timestamp(ts:int | float | tuple | time.struct_time | datetime.datetime) -> strFormats a timestamp in the format used by HTTP.
func
tornado.httputil.parse_body_arguments(content_type:str, body:bytes, arguments:dict[str, list[bytes]], files:dict[str, list[HTTPFile]], headers:HTTPHeaders | None=None, *config:ParseBodyConfig | None=None) -> NoneParses a form request body.
func
tornado.httputil.parse_cookie(cookie:str) -> dict[str, str]Parse a ``Cookie`` HTTP header into a dict of name/value pairs.
func
tornado.httputil.parse_multipart_form_data(boundary:bytes, data:bytes, arguments:dict[str, list[bytes]], files:dict[str, list[HTTPFile]], *config:ParseMultipartConfig | None=None) -> NoneParses a ``multipart/form-data`` body.
func
tornado.httputil.split_host_and_port(netloc:str) -> tuple[str, int | None]Returns ``(host, port)`` tuple from ``netloc``.
class
tornado.ioloop.IOLoopAn I/O event loop.
method
tornado.ioloop.IOLoop.add_callback(callback:Callable, *args:Any, **kwargs:Any) -> NoneCalls the given callback on the next I/O loop iteration.
method
tornado.ioloop.IOLoop.add_callback_from_signal(callback:Callable, *args:Any, **kwargs:Any) -> NoneCalls the given callback on the next I/O loop iteration.
method
tornado.ioloop.IOLoop.add_timeout(deadline:float | datetime.timedelta, callback:Callable, *args:Any, **kwargs:Any) -> objectRuns the ``callback`` at the time ``deadline`` from the I/O loop.
method
tornado.ioloop.IOLoop.call_at(when:float, callback:Callable, *args:Any, **kwargs:Any) -> objectRuns the ``callback`` at the absolute time designated by ``when``.
method
tornado.ioloop.IOLoop.call_later(delay:float, callback:Callable, *args:Any, **kwargs:Any) -> objectRuns the ``callback`` after ``delay`` seconds have passed.
method
tornado.ioloop.IOLoop.clear_current() -> NoneClears the `IOLoop` for the current thread.
method
tornado.ioloop.IOLoop.clear_instance() -> NoneDeprecated alias for `clear_current()`.
method
tornado.ioloop.IOLoop.close(all_fds:bool=False) -> NoneCloses the `IOLoop`, freeing any resources used.
method
tornado.ioloop.IOLoop.install() -> NoneDeprecated alias for `make_current()`.
method
tornado.ioloop.IOLoop.instance() -> IOLoopDeprecated alias for `IOLoop.current()`.
method
tornado.ioloop.IOLoop.make_current() -> NoneMakes this the `IOLoop` for the current thread.
method
tornado.ioloop.IOLoop.remove_handler(fd:int | _Selectable) -> NoneStop listening for events on ``fd``.
method
tornado.ioloop.IOLoop.remove_timeout(timeout:object) -> NoneCancels a pending timeout.
method
tornado.ioloop.IOLoop.run_sync(func:Callable, timeout:float | None=None) -> AnyStarts the `IOLoop`, runs the given function, and stops the loop.
method
tornado.ioloop.IOLoop.spawn_callback(callback:Callable, *args:Any, **kwargs:Any) -> NoneCalls the given callback on the next IOLoop iteration.
method
tornado.ioloop.IOLoop.start() -> NoneStarts the I/O loop.
method
tornado.ioloop.IOLoop.stop() -> NoneStop the I/O loop.
method
tornado.ioloop.IOLoop.time() -> floatReturns the current time according to the `IOLoop`'s clock.
method
tornado.ioloop.IOLoop.update_handler(fd:int | _Selectable, events:int) -> NoneChanges the events we listen for ``fd``.
class
tornado.ioloop.PeriodicCallbackSchedules the given callback to be called periodically.
method
tornado.ioloop.PeriodicCallback.start() -> NoneStarts the timer.
method
tornado.ioloop.PeriodicCallback.stop() -> NoneStops the timer.
class
tornado.iostream.IOStreamSocket-based `IOStream` implementation.
method
tornado.iostream.IOStream.connect(address:Any, server_hostname:str | None=None) -> 'Future[_IOStreamType]'Connects the socket to a remote address without blocking.
class
tornado.iostream.PipeIOStreamPipe-based `IOStream` implementation.
class
tornado.iostream.StreamClosedErrorException raised by `IOStream` methods when the stream is closed.
class
tornado.iostream.UnsatisfiableReadErrorException raised when a read cannot be satisfied.
class
tornado.locale.CSVLocaleLocale implementation using tornado's CSV translation format.
class
tornado.locale.GettextLocaleLocale implementation using the `gettext` module.
class
tornado.locale.LocaleObject representing a locale.
method
tornado.locale.Locale.format_date(date:int | float | datetime.datetime, gmt_offset:int=0, relative:bool=True, shorter:bool=False, full_format:bool=False) -> strFormats the given date.
method
tornado.locale.Locale.format_day(date:datetime.datetime, gmt_offset:int=0, dow:bool=True) -> strFormats the given date as a day of week.
method
tornado.locale.Locale.friendly_number(value:int) -> strReturns a comma-separated number for the given integer.
method
tornado.locale.Locale.get(code:str) -> LocaleReturns the Locale for the given locale code.
method
tornado.locale.Locale.get_closest(*locale_codes:str) -> LocaleReturns the closest match for the given locale code.
method
tornado.locale.Locale.list(parts:Any) -> strReturns a comma-separated list for the given list of parts.
func
tornado.locale.get(*locale_codes:str) -> LocaleReturns the closest match for the given locale codes.
func
tornado.locale.get_supported_locales() -> Iterable[str]Returns a list of all the supported locale codes.
func
tornado.locale.load_translations(directory:str, encoding:str | None=None) -> NoneLoads translations from CSV files in a directory.
func
tornado.locale.set_default_locale(code:str) -> NoneSets the default locale.
method
tornado.locks.BoundedSemaphore.release() -> NoneIncrement the counter and wake one waiter.
method
tornado.locks.Condition.notify(n:int=1) -> NoneWake ``n`` waiters.
method
tornado.locks.Condition.notify_all() -> NoneWake all waiters.
method
tornado.locks.Condition.wait(timeout:float | datetime.timedelta | None=None) -> Awaitable[bool]Wait for `.notify`.
class
tornado.locks.EventAn event blocks coroutines until its internal flag is set to True.
method
tornado.locks.Event.clear() -> NoneReset the internal flag to ``False``.
method
tornado.locks.Event.is_set() -> boolReturn ``True`` if the internal flag is true.
method
tornado.locks.Event.set() -> NoneSet the internal flag to ``True``.
method
tornado.locks.Event.wait(timeout:float | datetime.timedelta | None=None) -> Awaitable[None]Block until the internal flag is true.
class
tornado.locks.LockA lock for coroutines.
method
tornado.locks.Lock.acquire(timeout:float | datetime.timedelta | None=None) -> Awaitable[_ReleasingContextManager]Attempt to lock.
method
tornado.locks.Lock.release() -> NoneUnlock.
method
tornado.locks.Semaphore.acquire(timeout:float | datetime.timedelta | None=None) -> Awaitable[_ReleasingContextManager]Decrement the counter.
method
tornado.locks.Semaphore.release() -> NoneIncrement the counter and wake one waiter.
class
tornado.log.LogFormatterLog formatter used in Tornado.
func
tornado.log.define_logging_options(options:Any=None) -> NoneAdd logging-related flags to ``options``.
func
tornado.log.enable_pretty_logging(options:Any=None, logger:logging.Logger | None=None) -> NoneTurns on formatted logging output as configured.
class
tornado.netutil.DefaultExecutorResolverResolver implementation using `.IOLoop.run_in_executor`.
class
tornado.netutil.DefaultLoopResolverResolver implementation using `asyncio.loop.getaddrinfo`.
class
tornado.netutil.ExecutorResolverResolver implementation using a `concurrent.futures.Executor`.
class
tornado.netutil.OverrideResolverWraps a resolver with a mapping of overrides.
class
tornado.netutil.ResolverConfigurable asynchronous DNS resolver interface.
method
tornado.netutil.Resolver.close() -> NoneCloses the `Resolver`, freeing any resources used.
method
tornado.netutil.Resolver.resolve(host:str, port:int, family:socket.AddressFamily=socket.AF_UNSPEC) -> Awaitable[list[tuple[int, Any]]]Resolves an address.
class
tornado.netutil.ThreadedResolverMultithreaded non-blocking `Resolver` implementation.
func
tornado.netutil.bind_unix_socket(file:str, mode:int=384, backlog:int=_DEFAULT_BACKLOG) -> socket.socketCreates a listening unix socket.
func
tornado.netutil.is_valid_ip(ip:str) -> boolReturns ``True`` if the given string is a well-formed IP address.
class
tornado.options.ErrorException raised by errors in the options module.
class
tornado.options.OptionParserA collection of options, a dictionary with object-like access.
method
tornado.options.OptionParser.as_dict() -> dict[str, Any]The names and values of all options.
method
tornado.options.OptionParser.group_dict(group:str) -> dict[str, Any]The names and values of options in a group.
method
tornado.options.OptionParser.groups() -> set[str]The set of option-groups created by ``define``.
method
tornado.options.OptionParser.items() -> Iterable[tuple[str, Any]]An iterable of (name, value) pairs.
method
tornado.options.OptionParser.parse_config_file(path:str, final:bool=True) -> NoneParses and loads the config file at the given path.
method
tornado.options.OptionParser.print_help(file:TextIO | None=None) -> NonePrints all the command line options to stderr (or another file).
func
tornado.options.add_parse_callback(callback:Callable[[], None]) -> NoneAdds a parse callback, to be invoked when option parsing is done.
func
tornado.options.parse_command_line(args:list[str] | None=None, final:bool=True) -> list[str]Parses global options from the command line.
func
tornado.options.parse_config_file(path:str, final:bool=True) -> NoneParses global options from a config file.
func
tornado.options.print_help(file:TextIO | None=None) -> NonePrints all the command line options to stderr (or another file).
func
tornado.platform.asyncio.to_asyncio_future(tornado_future:asyncio.Future) -> asyncio.FutureConvert a Tornado yieldable object to an `asyncio.Future`.
class
tornado.platform.caresresolver.CaresResolverName resolver based on the c-ares library.
class
tornado.process.SubprocessWraps ``subprocess.Popen`` with IOStream support.
method
tornado.process.Subprocess.initialize() -> NoneInitializes the ``SIGCHLD`` handler.
method
tornado.process.Subprocess.set_exit_callback(callback:Callable[[int], None]) -> NoneRuns ``callback`` when this process exits.
method
tornado.process.Subprocess.uninitialize() -> NoneRemoves the ``SIGCHLD`` handler.
method
tornado.process.Subprocess.wait_for_exit(raise_error:bool=True) -> 'Future[int]'Returns a `.Future` which resolves when the process exits.
func
tornado.process.cpu_count() -> intReturns the number of processors on this machine.
func
tornado.process.fork_processes(num_processes:int | None, max_restarts:int | None=None) -> intStarts multiple worker processes.
func
tornado.process.task_id() -> int | NoneReturns the current task id, if any.
class
tornado.queues.LifoQueueA `.Queue` that retrieves the most recently put items first.
class
tornado.queues.QueueCoordinate producer and consumer coroutines.
method
tornado.queues.Queue.get(timeout:float | datetime.timedelta | None=None) -> Awaitable[_T]Remove and return an item from the queue.
method
tornado.queues.Queue.get_nowait() -> _TRemove and return an item from the queue without blocking.
method
tornado.queues.Queue.join(timeout:float | datetime.timedelta | None=None) -> Awaitable[None]Block until all items in the queue are processed.
method
tornado.queues.Queue.maxsize() -> intNumber of items allowed in the queue.
method
tornado.queues.Queue.put_nowait(item:_T) -> NonePut an item into the queue without blocking.
method
tornado.queues.Queue.qsize() -> intNumber of items in the queue.
method
tornado.queues.Queue.task_done() -> NoneIndicate that a formerly enqueued task is complete.
class
tornado.queues.QueueEmptyRaised by `.Queue.get_nowait` when the queue has no items.
class
tornado.routing.AnyMatchesMatches any request.
class
tornado.routing.MatcherRepresents a matcher for request features.
method
tornado.routing.Matcher.match(request:httputil.HTTPServerRequest) -> dict[str, Any] | NoneMatches current instance against the request.
method
tornado.routing.Matcher.reverse(*args:Any) -> str | NoneReconstructs full url from matcher instance and additional arguments.
class
tornado.routing.PathMatchesMatches requests with paths specified by ``path_pattern`` regex.
class
tornado.routing.ReversibleRuleRouterA rule-based router that implements ``reverse_url`` method.
class
tornado.routing.RouterAbstract router interface.
class
tornado.routing.RuleA routing rule.
class
tornado.routing.RuleRouterRule-based router implementation.
method
tornado.routing.RuleRouter.add_rules(rules:_RuleList) -> NoneAppends new rules to the router.
method
tornado.routing.RuleRouter.process_rule(rule:'Rule') -> 'Rule'Override this method for additional preprocessing of each rule.
class
tornado.routing.URLSpecSpecifies mappings between URLs and handlers.
class
tornado.simple_httpclient.HTTPTimeoutErrorError raised by SimpleAsyncHTTPClient on timeout.
class
tornado.simple_httpclient.SimpleAsyncHTTPClientNon-blocking HTTP client with no external dependencies.
class
tornado.tcpclient.TCPClientA non-blocking TCP connection factory.
class
tornado.tcpserver.TCPServerA non-blocking, single-threaded TCP server.
method
tornado.tcpserver.TCPServer.add_socket(socket:socket.socket) -> NoneSingular version of `add_sockets`.
method
tornado.tcpserver.TCPServer.add_sockets(sockets:Iterable[socket.socket]) -> NoneMakes this server start accepting connections on the given sockets.
method
tornado.tcpserver.TCPServer.start(num_processes:int | None=1, max_restarts:int | None=None) -> NoneStarts this server in the `.IOLoop`.
method
tornado.tcpserver.TCPServer.stop() -> NoneStops listening for new connections.
class
tornado.template.BaseLoaderBase class for template loaders.
method
tornado.template.BaseLoader.load(name:str, parent_path:str | None=None) -> TemplateLoads a template.
method
tornado.template.BaseLoader.reset() -> NoneResets the cache of compiled templates.
method
tornado.template.BaseLoader.resolve_path(name:str, parent_path:str | None=None) -> strConverts a possibly-relative path to absolute (used internally).
class
tornado.template.DictLoaderA template loader that loads from a dictionary.
class
tornado.template.LoaderA template loader that loads from a single root directory.
class
tornado.template.ParseErrorRaised for template syntax errors.
class
tornado.template.TemplateA compiled template.
method
tornado.template.Template.generate(**kwargs:Any) -> bytesGenerate this template with the given arguments.
func
tornado.template.filter_whitespace(mode:str, text:str) -> strTransform whitespace in ``text`` according to ``mode``.
class
tornado.testing.AsyncHTTPSTestCaseA test case that starts an HTTPS server.
class
tornado.testing.AsyncHTTPTestCaseA test case that starts up an HTTP server.
method
tornado.testing.AsyncHTTPTestCase.fetch(path:str, raise_error:bool=False, **kwargs:Any) -> HTTPResponseConvenience method to synchronously fetch a URL.
method
tornado.testing.AsyncHTTPTestCase.get_http_port() -> intReturns the port used by the server.
method
tornado.testing.AsyncHTTPTestCase.get_url(path:str) -> strReturns an absolute url for the given path on the test server.
class
tornado.testing.ExpectLogContext manager to capture and suppress expected log output.
func
tornado.testing.bind_unused_port(reuse_port:bool=False, address:str='127.0.0.1') -> tuple[socket.socket, int]Binds a server socket to an available port on localhost.
func
tornado.testing.get_async_test_timeout() -> floatGet the global timeout setting for async tests.
func
tornado.testing.main(**kwargs:Any) -> NoneA simple test runner.
func
tornado.testing.setup_with_context_manager(testcase:unittest.TestCase, cm:Any) -> AnyUse a context manager to setUp a test case.
class
tornado.util.ArgReplacerReplaces one value in an ``args, kwargs`` pair.
method
tornado.util.ArgReplacer.replace(new_value:Any, args:Sequence[Any], kwargs:dict[str, Any]) -> tuple[Any, Sequence[Any], dict[str, Any]]Replace the named argument in ``args, kwargs`` with ``new_value``.
class
tornado.util.ConfigurableBase class for configurable interfaces.
method
tornado.util.Configurable.configurable_base() -> type[Configurable]Returns the base class of a configurable hierarchy.
method
tornado.util.Configurable.configure(impl:None | str | type[Configurable], **kwargs:Any) -> NoneSets the class to use when the base class is instantiated.
method
tornado.util.Configurable.configured_class() -> type[Configurable]Returns the currently configured class.
class
tornado.util.GzipDecompressorStreaming gzip decompressor.
method
tornado.util.GzipDecompressor.decompress(value:bytes, max_length:int=0) -> bytesDecompress a chunk, returning newly-available data.
method
tornado.util.GzipDecompressor.unconsumed_tail() -> bytesReturns the unconsumed portion left over
func
tornado.util.errno_from_exception(e:BaseException) -> int | NoneProvides the errno from an Exception object.
func
tornado.util.import_object(name:str) -> AnyImports an object by name.
func
tornado.util.re_unescape(s:str) -> strUnescape a string escaped by `re.escape`.
func
tornado.util.timedelta_to_seconds(td:datetime.timedelta) -> floatEquivalent to ``td.total_seconds()`` (introduced in Python 2.7).
class
tornado.web.ApplicationA collection of request handlers that make up a web application.
method
tornado.web.Application.add_handlers(host_pattern:str, host_handlers:_RuleList) -> NoneAppends the given handlers to our handler list.
method
tornado.web.Application.log_request(handler:RequestHandler) -> NoneWrites a completed HTTP request to the logs.
class
tornado.web.FallbackHandlerA `RequestHandler` that wraps another HTTP server callback.
class
tornado.web.GZipContentEncodingApplies the gzip content encoding to the response.
class
tornado.web.HTTPErrorAn exception that will turn into an HTTP error response.
method
tornado.web.HTTPError.log_message() -> str | NoneA backwards compatible way of accessing log_message.
class
tornado.web.MissingArgumentErrorException raised by `RequestHandler.get_argument`.
class
tornado.web.RedirectHandlerRedirects the client to the given URL for all GET requests.
class
tornado.web.RequestHandlerBase class for HTTP request handlers.
method
tornado.web.RequestHandler.add_header(name:str, value:_HeaderTypes) -> NoneAdds the given response header and value.
method
tornado.web.RequestHandler.clear() -> NoneResets all headers and content for this response.
method
tornado.web.RequestHandler.clear_all_cookies(**kwargs:Any) -> NoneAttempt to delete all the cookies the user sent with this request.
method
tornado.web.RequestHandler.clear_cookie(name:str, **kwargs:Any) -> NoneDeletes the cookie with the given name.
method
tornado.web.RequestHandler.clear_header(name:str) -> NoneClears an outgoing header, undoing a previous `set_header` call.
method
tornado.web.RequestHandler.compute_etag() -> str | NoneComputes the etag header to be used for this request.
method
tornado.web.RequestHandler.create_signed_value(name:str, value:str | bytes, version:int | None=None) -> bytesSigns and timestamps a string so it cannot be forged.
method
tornado.web.RequestHandler.create_template_loader(template_path:str) -> template.BaseLoaderReturns a new template loader for the given path.
method
tornado.web.RequestHandler.current_user() -> AnyThe authenticated user for this request.
method
tornado.web.RequestHandler.data_received(chunk:bytes) -> Awaitable[None] | NoneImplement this method to handle streamed request data.
method
tornado.web.RequestHandler.decode_argument(value:bytes, name:str | None=None) -> strDecodes an argument from the request.
method
tornado.web.RequestHandler.detach() -> iostream.IOStreamTake control of the underlying stream.
method
tornado.web.RequestHandler.finish(chunk:str | bytes | dict | None=None) -> 'Future[None]'Finishes this response, ending the HTTP request.
method
tornado.web.RequestHandler.flush(include_footers:bool=False) -> 'Future[None]'Flushes the current output buffer to the network.
method
tornado.web.RequestHandler.get_arguments(name:str, strip:bool=True) -> list[str]Returns a list of the arguments with the given name.
method
tornado.web.RequestHandler.get_body_arguments(name:str, strip:bool=True) -> list[str]Returns a list of the body arguments with the given name.
method
tornado.web.RequestHandler.get_browser_locale(default:str='en_US') -> tornado.locale.LocaleDetermines the user's locale from ``Accept-Language`` header.
method
tornado.web.RequestHandler.get_login_url() -> strOverride to customize the login URL based on the request.
method
tornado.web.RequestHandler.get_query_arguments(name:str, strip:bool=True) -> list[str]Returns a list of the query arguments with the given name.
method
tornado.web.RequestHandler.get_signed_cookie_key_version(name:str, value:str | None=None) -> int | NoneReturns the signing key version of the secure cookie.
method
tornado.web.RequestHandler.get_status() -> intReturns the status code for our response.
method
tornado.web.RequestHandler.get_template_path() -> str | NoneOverride to customize template path for each handler.
method
tornado.web.RequestHandler.locale() -> tornado.locale.LocaleThe locale for the current session.
method
tornado.web.RequestHandler.on_finish() -> NoneCalled after the end of a request.
method
tornado.web.RequestHandler.redirect(url:str, permanent:bool=False, status:int | None=None) -> NoneSends a redirect to the given (optionally relative) URL.
method
tornado.web.RequestHandler.render(template_name:str, **kwargs:Any) -> 'Future[None]'Renders the template with the given arguments as the response.
method
tornado.web.RequestHandler.render_string(template_name:str, **kwargs:Any) -> bytesGenerate the given template with the given arguments.
method
tornado.web.RequestHandler.require_setting(name:str, feature:str='this feature') -> NoneRaises an exception if the given app setting is not defined.
method
tornado.web.RequestHandler.reverse_url(name:str, *args:Any) -> strAlias for `Application.reverse_url`.
method
tornado.web.RequestHandler.send_error(status_code:int=500, **kwargs:Any) -> NoneSends the given HTTP error code to the browser.
method
tornado.web.RequestHandler.set_header(name:str, value:_HeaderTypes) -> NoneSets the given response header name and value.
method
tornado.web.RequestHandler.set_status(status_code:int, reason:str | None=None) -> NoneSets the status code for our response.
method
tornado.web.RequestHandler.write(chunk:str | bytes | dict) -> NoneWrites the given chunk to the output buffer.
method
tornado.web.RequestHandler.write_error(status_code:int, **kwargs:Any) -> NoneOverride to implement custom error pages.
method
tornado.web.RequestHandler.xsrf_token() -> bytesThe XSRF-prevention token for the current user/session.
method
tornado.web.StaticFileHandler.compute_etag() -> str | NoneSets the ``Etag`` header based on static url version.
method
tornado.web.StaticFileHandler.get_absolute_path(root:str, path:str) -> strReturns the absolute location of ``path`` relative to ``root``.
method
tornado.web.StaticFileHandler.get_cache_time(path:str, modified:datetime.datetime | None, mime_type:str) -> intOverride to customize cache control behavior.
method
tornado.web.StaticFileHandler.get_content_version(abspath:str) -> strReturns a version string for the resource at the given path.
method
tornado.web.StaticFileHandler.get_version(settings:dict[str, Any], path:str) -> str | NoneGenerate the version string to be used in static URLs.
method
tornado.web.StaticFileHandler.make_static_url(settings:dict[str, Any], path:str, include_version:bool=True) -> strConstructs a versioned url for the given path.
method
tornado.web.StaticFileHandler.parse_url_path(url_path:str) -> strConverts a static URL path into a filesystem path.
method
tornado.web.StaticFileHandler.set_extra_headers(path:str) -> NoneFor subclass to add extra headers to the response
method
tornado.web.StaticFileHandler.set_headers() -> NoneSets the content and caching headers on the response.
method
tornado.web.StaticFileHandler.validate_absolute_path(root:str, absolute_path:str) -> str | NoneValidate and return the absolute path.
class
tornado.web.TemplateModuleUIModule that simply renders the given template.
class
tornado.web.UIModuleA re-usable, modular UI unit on a page.
method
tornado.web.UIModule.render(*args:Any, **kwargs:Any) -> str | bytesOverride in subclasses to return this module's output.
method
tornado.web.UIModule.render_string(path:str, **kwargs:Any) -> bytesRenders a template and returns it as a string.
class
tornado.websocket.WebSocketClientConnectionWebSocket client connection.
method
tornado.websocket.WebSocketClientConnection.close(code:int | None=None, reason:str | None=None) -> NoneCloses the websocket connection.
method
tornado.websocket.WebSocketClientConnection.ping(data:bytes=b'') -> NoneSend ping frame to the remote end.
method
tornado.websocket.WebSocketClientConnection.selected_subprotocol() -> str | NoneThe subprotocol selected by the server.
method
tornado.websocket.WebSocketClientConnection.write_message(message:str | bytes | dict[str, Any], binary:bool=False) -> 'Future[None]'Sends a message to the WebSocket server.
class
tornado.websocket.WebSocketClosedErrorRaised by operations on a closed connection.
class
tornado.websocket.WebSocketHandlerSubclass this class to create a basic WebSocket handler.
method
tornado.websocket.WebSocketHandler.check_origin(origin:str) -> boolOverride to enable support for allowing alternate origins.
method
tornado.websocket.WebSocketHandler.close(code:int | None=None, reason:str | None=None) -> NoneCloses this Web Socket.
method
tornado.websocket.WebSocketHandler.max_message_size() -> intMaximum allowed message size.
method
tornado.websocket.WebSocketHandler.on_close() -> NoneInvoked when the WebSocket is closed.
method
tornado.websocket.WebSocketHandler.on_ping(data:bytes) -> NoneInvoked when the a ping frame is received.
method
tornado.websocket.WebSocketHandler.on_pong(data:bytes) -> NoneInvoked when the response to a ping frame is received.
method
tornado.websocket.WebSocketHandler.ping(data:str | bytes=b'') -> NoneSend ping frame to the remote end.
method
tornado.websocket.WebSocketHandler.ping_interval() -> float | NoneThe interval for sending websocket pings.
method
tornado.websocket.WebSocketHandler.ping_timeout() -> float | NoneTimeout if no pong is received in this many seconds.
method
tornado.websocket.WebSocketHandler.select_subprotocol(subprotocols:list[str]) -> str | NoneOverride to implement subprotocol negotiation.
method
tornado.websocket.WebSocketHandler.selected_subprotocol() -> str | NoneThe subprotocol returned by `select_subprotocol`.
method
tornado.websocket.WebSocketHandler.set_nodelay(value:bool) -> NoneSet the no-delay flag for this stream.
class
tornado.websocket.WebSocketProtocolBase class for WebSocket protocol versions.
class
tornado.websocket.WebSocketProtocol13Implementation of the WebSocket protocol from RFC 6455.
method
tornado.websocket.WebSocketProtocol13.close(code:int | None=None, reason:str | None=None) -> NoneCloses the WebSocket connection.
method
tornado.websocket.WebSocketProtocol13.is_closing() -> boolReturn ``True`` if this connection is closing.
method
tornado.websocket.WebSocketProtocol13.write_ping(data:bytes) -> NoneSend ping frame.
About this data
These signatures were extracted from the public source of tornadoweb/tornado
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.