id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
26,800
tornadoweb/tornado
tornado/iostream.py
BaseIOStream._read_from_buffer
def _read_from_buffer(self, pos: int) -> None: """Attempts to complete the currently-pending read from the buffer. The argument is either a position in the read buffer or None, as returned by _find_read_pos. """ self._read_bytes = self._read_delimiter = self._read_regex = None ...
python
def _read_from_buffer(self, pos: int) -> None: """Attempts to complete the currently-pending read from the buffer. The argument is either a position in the read buffer or None, as returned by _find_read_pos. """ self._read_bytes = self._read_delimiter = self._read_regex = None ...
[ "def", "_read_from_buffer", "(", "self", ",", "pos", ":", "int", ")", "->", "None", ":", "self", ".", "_read_bytes", "=", "self", ".", "_read_delimiter", "=", "self", ".", "_read_regex", "=", "None", "self", ".", "_read_partial", "=", "False", "self", "....
Attempts to complete the currently-pending read from the buffer. The argument is either a position in the read buffer or None, as returned by _find_read_pos.
[ "Attempts", "to", "complete", "the", "currently", "-", "pending", "read", "from", "the", "buffer", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L887-L895
26,801
tornadoweb/tornado
tornado/iostream.py
BaseIOStream._find_read_pos
def _find_read_pos(self) -> Optional[int]: """Attempts to find a position in the read buffer that satisfies the currently-pending read. Returns a position in the buffer if the current read can be satisfied, or None if it cannot. """ if self._read_bytes is not None and ( ...
python
def _find_read_pos(self) -> Optional[int]: """Attempts to find a position in the read buffer that satisfies the currently-pending read. Returns a position in the buffer if the current read can be satisfied, or None if it cannot. """ if self._read_bytes is not None and ( ...
[ "def", "_find_read_pos", "(", "self", ")", "->", "Optional", "[", "int", "]", ":", "if", "self", ".", "_read_bytes", "is", "not", "None", "and", "(", "self", ".", "_read_buffer_size", ">=", "self", ".", "_read_bytes", "or", "(", "self", ".", "_read_parti...
Attempts to find a position in the read buffer that satisfies the currently-pending read. Returns a position in the buffer if the current read can be satisfied, or None if it cannot.
[ "Attempts", "to", "find", "a", "position", "in", "the", "read", "buffer", "that", "satisfies", "the", "currently", "-", "pending", "read", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L897-L937
26,802
tornadoweb/tornado
tornado/iostream.py
BaseIOStream._is_connreset
def _is_connreset(self, exc: BaseException) -> bool: """Return ``True`` if exc is ECONNRESET or equivalent. May be overridden in subclasses. """ return ( isinstance(exc, (socket.error, IOError)) and errno_from_exception(exc) in _ERRNO_CONNRESET )
python
def _is_connreset(self, exc: BaseException) -> bool: """Return ``True`` if exc is ECONNRESET or equivalent. May be overridden in subclasses. """ return ( isinstance(exc, (socket.error, IOError)) and errno_from_exception(exc) in _ERRNO_CONNRESET )
[ "def", "_is_connreset", "(", "self", ",", "exc", ":", "BaseException", ")", "->", "bool", ":", "return", "(", "isinstance", "(", "exc", ",", "(", "socket", ".", "error", ",", "IOError", ")", ")", "and", "errno_from_exception", "(", "exc", ")", "in", "_...
Return ``True`` if exc is ECONNRESET or equivalent. May be overridden in subclasses.
[ "Return", "True", "if", "exc", "is", "ECONNRESET", "or", "equivalent", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1054-L1062
26,803
tornadoweb/tornado
tornado/iostream.py
IOStream.connect
def connect( self: _IOStreamType, address: tuple, server_hostname: str = None ) -> "Future[_IOStreamType]": """Connects the socket to a remote address without blocking. May only be called if the socket passed to the constructor was not previously connected. The address parameter is...
python
def connect( self: _IOStreamType, address: tuple, server_hostname: str = None ) -> "Future[_IOStreamType]": """Connects the socket to a remote address without blocking. May only be called if the socket passed to the constructor was not previously connected. The address parameter is...
[ "def", "connect", "(", "self", ":", "_IOStreamType", ",", "address", ":", "tuple", ",", "server_hostname", ":", "str", "=", "None", ")", "->", "\"Future[_IOStreamType]\"", ":", "self", ".", "_connecting", "=", "True", "future", "=", "Future", "(", ")", "# ...
Connects the socket to a remote address without blocking. May only be called if the socket passed to the constructor was not previously connected. The address parameter is in the same format as for `socket.connect <socket.socket.connect>` for the type of socket passed to the IOStream c...
[ "Connects", "the", "socket", "to", "a", "remote", "address", "without", "blocking", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1148-L1219
26,804
tornadoweb/tornado
tornado/iostream.py
IOStream.start_tls
def start_tls( self, server_side: bool, ssl_options: Union[Dict[str, Any], ssl.SSLContext] = None, server_hostname: str = None, ) -> Awaitable["SSLIOStream"]: """Convert this `IOStream` to an `SSLIOStream`. This enables protocols that begin in clear-text mode and ...
python
def start_tls( self, server_side: bool, ssl_options: Union[Dict[str, Any], ssl.SSLContext] = None, server_hostname: str = None, ) -> Awaitable["SSLIOStream"]: """Convert this `IOStream` to an `SSLIOStream`. This enables protocols that begin in clear-text mode and ...
[ "def", "start_tls", "(", "self", ",", "server_side", ":", "bool", ",", "ssl_options", ":", "Union", "[", "Dict", "[", "str", ",", "Any", "]", ",", "ssl", ".", "SSLContext", "]", "=", "None", ",", "server_hostname", ":", "str", "=", "None", ",", ")", ...
Convert this `IOStream` to an `SSLIOStream`. This enables protocols that begin in clear-text mode and switch to SSL after some initial negotiation (such as the ``STARTTLS`` extension to SMTP and IMAP). This method cannot be used if there are outstanding reads or writes on the s...
[ "Convert", "this", "IOStream", "to", "an", "SSLIOStream", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1221-L1295
26,805
tornadoweb/tornado
tornado/iostream.py
SSLIOStream._verify_cert
def _verify_cert(self, peercert: Any) -> bool: """Returns ``True`` if peercert is valid according to the configured validation mode and hostname. The ssl handshake already tested the certificate for a valid CA signature; the only thing that remains is to check the hostname. ...
python
def _verify_cert(self, peercert: Any) -> bool: """Returns ``True`` if peercert is valid according to the configured validation mode and hostname. The ssl handshake already tested the certificate for a valid CA signature; the only thing that remains is to check the hostname. ...
[ "def", "_verify_cert", "(", "self", ",", "peercert", ":", "Any", ")", "->", "bool", ":", "if", "isinstance", "(", "self", ".", "_ssl_options", ",", "dict", ")", ":", "verify_mode", "=", "self", ".", "_ssl_options", ".", "get", "(", "\"cert_reqs\"", ",", ...
Returns ``True`` if peercert is valid according to the configured validation mode and hostname. The ssl handshake already tested the certificate for a valid CA signature; the only thing that remains is to check the hostname.
[ "Returns", "True", "if", "peercert", "is", "valid", "according", "to", "the", "configured", "validation", "mode", "and", "hostname", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1442-L1467
26,806
tornadoweb/tornado
tornado/iostream.py
SSLIOStream.wait_for_handshake
def wait_for_handshake(self) -> "Future[SSLIOStream]": """Wait for the initial SSL handshake to complete. If a ``callback`` is given, it will be called with no arguments once the handshake is complete; otherwise this method returns a `.Future` which will resolve to the stream it...
python
def wait_for_handshake(self) -> "Future[SSLIOStream]": """Wait for the initial SSL handshake to complete. If a ``callback`` is given, it will be called with no arguments once the handshake is complete; otherwise this method returns a `.Future` which will resolve to the stream it...
[ "def", "wait_for_handshake", "(", "self", ")", "->", "\"Future[SSLIOStream]\"", ":", "if", "self", ".", "_ssl_connect_future", "is", "not", "None", ":", "raise", "RuntimeError", "(", "\"Already waiting\"", ")", "future", "=", "self", ".", "_ssl_connect_future", "=...
Wait for the initial SSL handshake to complete. If a ``callback`` is given, it will be called with no arguments once the handshake is complete; otherwise this method returns a `.Future` which will resolve to the stream itself after the handshake is complete. Once the handshake ...
[ "Wait", "for", "the", "initial", "SSL", "handshake", "to", "complete", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1527-L1557
26,807
tornadoweb/tornado
tornado/log.py
enable_pretty_logging
def enable_pretty_logging(options: Any = None, logger: logging.Logger = None) -> None: """Turns on formatted logging output as configured. This is called automatically by `tornado.options.parse_command_line` and `tornado.options.parse_config_file`. """ if options is None: import tornado.opt...
python
def enable_pretty_logging(options: Any = None, logger: logging.Logger = None) -> None: """Turns on formatted logging output as configured. This is called automatically by `tornado.options.parse_command_line` and `tornado.options.parse_config_file`. """ if options is None: import tornado.opt...
[ "def", "enable_pretty_logging", "(", "options", ":", "Any", "=", "None", ",", "logger", ":", "logging", ".", "Logger", "=", "None", ")", "->", "None", ":", "if", "options", "is", "None", ":", "import", "tornado", ".", "options", "options", "=", "tornado"...
Turns on formatted logging output as configured. This is called automatically by `tornado.options.parse_command_line` and `tornado.options.parse_config_file`.
[ "Turns", "on", "formatted", "logging", "output", "as", "configured", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/log.py#L211-L256
26,808
tornadoweb/tornado
tornado/log.py
define_logging_options
def define_logging_options(options: Any = None) -> None: """Add logging-related flags to ``options``. These options are present automatically on the default options instance; this method is only necessary if you have created your own `.OptionParser`. .. versionadded:: 4.2 This function existed...
python
def define_logging_options(options: Any = None) -> None: """Add logging-related flags to ``options``. These options are present automatically on the default options instance; this method is only necessary if you have created your own `.OptionParser`. .. versionadded:: 4.2 This function existed...
[ "def", "define_logging_options", "(", "options", ":", "Any", "=", "None", ")", "->", "None", ":", "if", "options", "is", "None", ":", "# late import to prevent cycle", "import", "tornado", ".", "options", "options", "=", "tornado", ".", "options", ".", "option...
Add logging-related flags to ``options``. These options are present automatically on the default options instance; this method is only necessary if you have created your own `.OptionParser`. .. versionadded:: 4.2 This function existed in prior versions but was broken and undocumented until 4.2.
[ "Add", "logging", "-", "related", "flags", "to", "options", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/log.py#L259-L337
26,809
tornadoweb/tornado
tornado/simple_httpclient.py
SimpleAsyncHTTPClient.initialize
def initialize( # type: ignore self, max_clients: int = 10, hostname_mapping: Dict[str, str] = None, max_buffer_size: int = 104857600, resolver: Resolver = None, defaults: Dict[str, Any] = None, max_header_size: int = None, max_body_size: int = None, ...
python
def initialize( # type: ignore self, max_clients: int = 10, hostname_mapping: Dict[str, str] = None, max_buffer_size: int = 104857600, resolver: Resolver = None, defaults: Dict[str, Any] = None, max_header_size: int = None, max_body_size: int = None, ...
[ "def", "initialize", "(", "# type: ignore", "self", ",", "max_clients", ":", "int", "=", "10", ",", "hostname_mapping", ":", "Dict", "[", "str", ",", "str", "]", "=", "None", ",", "max_buffer_size", ":", "int", "=", "104857600", ",", "resolver", ":", "Re...
Creates a AsyncHTTPClient. Only a single AsyncHTTPClient instance exists per IOLoop in order to provide limitations on the number of pending connections. ``force_instance=True`` may be used to suppress this behavior. Note that because of this implicit reuse, unless ``force_instance`` ...
[ "Creates", "a", "AsyncHTTPClient", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/simple_httpclient.py#L89-L157
26,810
tornadoweb/tornado
tornado/simple_httpclient.py
SimpleAsyncHTTPClient._on_timeout
def _on_timeout(self, key: object, info: str = None) -> None: """Timeout callback of request. Construct a timeout HTTPResponse when a timeout occurs. :arg object key: A simple object to mark the request. :info string key: More detailed timeout information. """ request, ...
python
def _on_timeout(self, key: object, info: str = None) -> None: """Timeout callback of request. Construct a timeout HTTPResponse when a timeout occurs. :arg object key: A simple object to mark the request. :info string key: More detailed timeout information. """ request, ...
[ "def", "_on_timeout", "(", "self", ",", "key", ":", "object", ",", "info", ":", "str", "=", "None", ")", "->", "None", ":", "request", ",", "callback", ",", "timeout_handle", "=", "self", ".", "waiting", "[", "key", "]", "self", ".", "queue", ".", ...
Timeout callback of request. Construct a timeout HTTPResponse when a timeout occurs. :arg object key: A simple object to mark the request. :info string key: More detailed timeout information.
[ "Timeout", "callback", "of", "request", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/simple_httpclient.py#L229-L248
26,811
tornadoweb/tornado
tornado/simple_httpclient.py
_HTTPConnection._on_timeout
def _on_timeout(self, info: str = None) -> None: """Timeout callback of _HTTPConnection instance. Raise a `HTTPTimeoutError` when a timeout occurs. :info string key: More detailed timeout information. """ self._timeout = None error_message = "Timeout {0}".format(info) i...
python
def _on_timeout(self, info: str = None) -> None: """Timeout callback of _HTTPConnection instance. Raise a `HTTPTimeoutError` when a timeout occurs. :info string key: More detailed timeout information. """ self._timeout = None error_message = "Timeout {0}".format(info) i...
[ "def", "_on_timeout", "(", "self", ",", "info", ":", "str", "=", "None", ")", "->", "None", ":", "self", ".", "_timeout", "=", "None", "error_message", "=", "\"Timeout {0}\"", ".", "format", "(", "info", ")", "if", "info", "else", "\"Timeout\"", "if", ...
Timeout callback of _HTTPConnection instance. Raise a `HTTPTimeoutError` when a timeout occurs. :info string key: More detailed timeout information.
[ "Timeout", "callback", "of", "_HTTPConnection", "instance", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/simple_httpclient.py#L474-L486
26,812
tornadoweb/tornado
tornado/auth.py
_oauth10a_signature
def _oauth10a_signature( consumer_token: Dict[str, Any], method: str, url: str, parameters: Dict[str, Any] = {}, token: Dict[str, Any] = None, ) -> bytes: """Calculates the HMAC-SHA1 OAuth 1.0a signature for the given request. See http://oauth.net/core/1.0a/#signing_process """ part...
python
def _oauth10a_signature( consumer_token: Dict[str, Any], method: str, url: str, parameters: Dict[str, Any] = {}, token: Dict[str, Any] = None, ) -> bytes: """Calculates the HMAC-SHA1 OAuth 1.0a signature for the given request. See http://oauth.net/core/1.0a/#signing_process """ part...
[ "def", "_oauth10a_signature", "(", "consumer_token", ":", "Dict", "[", "str", ",", "Any", "]", ",", "method", ":", "str", ",", "url", ":", "str", ",", "parameters", ":", "Dict", "[", "str", ",", "Any", "]", "=", "{", "}", ",", "token", ":", "Dict",...
Calculates the HMAC-SHA1 OAuth 1.0a signature for the given request. See http://oauth.net/core/1.0a/#signing_process
[ "Calculates", "the", "HMAC", "-", "SHA1", "OAuth", "1", ".", "0a", "signature", "for", "the", "given", "request", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L1130-L1162
26,813
tornadoweb/tornado
tornado/auth.py
OpenIdMixin.authenticate_redirect
def authenticate_redirect( self, callback_uri: str = None, ax_attrs: List[str] = ["name", "email", "language", "username"], ) -> None: """Redirects to the authentication URL for this service. After authentication, the service will redirect back to the given callback ...
python
def authenticate_redirect( self, callback_uri: str = None, ax_attrs: List[str] = ["name", "email", "language", "username"], ) -> None: """Redirects to the authentication URL for this service. After authentication, the service will redirect back to the given callback ...
[ "def", "authenticate_redirect", "(", "self", ",", "callback_uri", ":", "str", "=", "None", ",", "ax_attrs", ":", "List", "[", "str", "]", "=", "[", "\"name\"", ",", "\"email\"", ",", "\"language\"", ",", "\"username\"", "]", ",", ")", "->", "None", ":", ...
Redirects to the authentication URL for this service. After authentication, the service will redirect back to the given callback URI with additional parameters including ``openid.mode``. We request the given attributes for the authenticated user by default (name, email, language, and u...
[ "Redirects", "to", "the", "authentication", "URL", "for", "this", "service", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L88-L114
26,814
tornadoweb/tornado
tornado/auth.py
OAuthMixin.get_authenticated_user
async def get_authenticated_user( self, http_client: httpclient.AsyncHTTPClient = None ) -> Dict[str, Any]: """Gets the OAuth authorized user and access token. This method should be called from the handler for your OAuth callback URL to complete the registration process. We run the ...
python
async def get_authenticated_user( self, http_client: httpclient.AsyncHTTPClient = None ) -> Dict[str, Any]: """Gets the OAuth authorized user and access token. This method should be called from the handler for your OAuth callback URL to complete the registration process. We run the ...
[ "async", "def", "get_authenticated_user", "(", "self", ",", "http_client", ":", "httpclient", ".", "AsyncHTTPClient", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "handler", "=", "cast", "(", "RequestHandler", ",", "self", ")", "reques...
Gets the OAuth authorized user and access token. This method should be called from the handler for your OAuth callback URL to complete the registration process. We run the callback with the authenticated user dictionary. This dictionary will contain an ``access_key`` which can be used ...
[ "Gets", "the", "OAuth", "authorized", "user", "and", "access", "token", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L336-L380
26,815
tornadoweb/tornado
tornado/auth.py
OAuthMixin._oauth_get_user_future
async def _oauth_get_user_future( self, access_token: Dict[str, Any] ) -> Dict[str, Any]: """Subclasses must override this to get basic information about the user. Should be a coroutine whose result is a dictionary containing information about the user, which may have been ...
python
async def _oauth_get_user_future( self, access_token: Dict[str, Any] ) -> Dict[str, Any]: """Subclasses must override this to get basic information about the user. Should be a coroutine whose result is a dictionary containing information about the user, which may have been ...
[ "async", "def", "_oauth_get_user_future", "(", "self", ",", "access_token", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "raise", "NotImplementedError", "(", ")" ]
Subclasses must override this to get basic information about the user. Should be a coroutine whose result is a dictionary containing information about the user, which may have been retrieved by using ``access_token`` to make a request to the service. The access token wi...
[ "Subclasses", "must", "override", "this", "to", "get", "basic", "information", "about", "the", "user", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L468-L490
26,816
tornadoweb/tornado
tornado/auth.py
OAuth2Mixin.oauth2_request
async def oauth2_request( self, url: str, access_token: str = None, post_args: Dict[str, Any] = None, **args: Any ) -> Any: """Fetches the given URL auth an OAuth2 access token. If the request is a POST, ``post_args`` should be provided. Query string ...
python
async def oauth2_request( self, url: str, access_token: str = None, post_args: Dict[str, Any] = None, **args: Any ) -> Any: """Fetches the given URL auth an OAuth2 access token. If the request is a POST, ``post_args`` should be provided. Query string ...
[ "async", "def", "oauth2_request", "(", "self", ",", "url", ":", "str", ",", "access_token", ":", "str", "=", "None", ",", "post_args", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ",", "*", "*", "args", ":", "Any", ")", "->", "Any", ":"...
Fetches the given URL auth an OAuth2 access token. If the request is a POST, ``post_args`` should be provided. Query string arguments should be given as keyword arguments. Example usage: ..testcode:: class MainHandler(tornado.web.RequestHandler, ...
[ "Fetches", "the", "given", "URL", "auth", "an", "OAuth2", "access", "token", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L605-L659
26,817
tornadoweb/tornado
tornado/auth.py
TwitterMixin.authenticate_redirect
async def authenticate_redirect(self, callback_uri: str = None) -> None: """Just like `~OAuthMixin.authorize_redirect`, but auto-redirects if authorized. This is generally the right interface to use if you are using Twitter for single-sign on. .. versionchanged:: 3.1 ...
python
async def authenticate_redirect(self, callback_uri: str = None) -> None: """Just like `~OAuthMixin.authorize_redirect`, but auto-redirects if authorized. This is generally the right interface to use if you are using Twitter for single-sign on. .. versionchanged:: 3.1 ...
[ "async", "def", "authenticate_redirect", "(", "self", ",", "callback_uri", ":", "str", "=", "None", ")", "->", "None", ":", "http", "=", "self", ".", "get_auth_http_client", "(", ")", "response", "=", "await", "http", ".", "fetch", "(", "self", ".", "_oa...
Just like `~OAuthMixin.authorize_redirect`, but auto-redirects if authorized. This is generally the right interface to use if you are using Twitter for single-sign on. .. versionchanged:: 3.1 Now returns a `.Future` and takes an optional callback, for compatibilit...
[ "Just", "like", "~OAuthMixin", ".", "authorize_redirect", "but", "auto", "-", "redirects", "if", "authorized", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L712-L732
26,818
tornadoweb/tornado
tornado/auth.py
GoogleOAuth2Mixin.get_authenticated_user
async def get_authenticated_user( self, redirect_uri: str, code: str ) -> Dict[str, Any]: """Handles the login for the Google user, returning an access token. The result is a dictionary containing an ``access_token`` field ([among others](https://developers.google.com/identity/proto...
python
async def get_authenticated_user( self, redirect_uri: str, code: str ) -> Dict[str, Any]: """Handles the login for the Google user, returning an access token. The result is a dictionary containing an ``access_token`` field ([among others](https://developers.google.com/identity/proto...
[ "async", "def", "get_authenticated_user", "(", "self", ",", "redirect_uri", ":", "str", ",", "code", ":", "str", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "# noqa: E501", "handler", "=", "cast", "(", "RequestHandler", ",", "self", ")", "http",...
Handles the login for the Google user, returning an access token. The result is a dictionary containing an ``access_token`` field ([among others](https://developers.google.com/identity/protocols/OAuth2WebServer#handlingtheresponse)). Unlike other ``get_authenticated_user`` methods in this packa...
[ "Handles", "the", "login", "for", "the", "Google", "user", "returning", "an", "access", "token", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L854-L916
26,819
tornadoweb/tornado
tornado/auth.py
FacebookGraphMixin.get_authenticated_user
async def get_authenticated_user( self, redirect_uri: str, client_id: str, client_secret: str, code: str, extra_fields: Dict[str, Any] = None, ) -> Optional[Dict[str, Any]]: """Handles the login for the Facebook user, returning a user object. Example ...
python
async def get_authenticated_user( self, redirect_uri: str, client_id: str, client_secret: str, code: str, extra_fields: Dict[str, Any] = None, ) -> Optional[Dict[str, Any]]: """Handles the login for the Facebook user, returning a user object. Example ...
[ "async", "def", "get_authenticated_user", "(", "self", ",", "redirect_uri", ":", "str", ",", "client_id", ":", "str", ",", "client_secret", ":", "str", ",", "code", ":", "str", ",", "extra_fields", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ...
Handles the login for the Facebook user, returning a user object. Example usage: .. testcode:: class FacebookGraphLoginHandler(tornado.web.RequestHandler, tornado.auth.FacebookGraphMixin): async def get(self): if ...
[ "Handles", "the", "login", "for", "the", "Facebook", "user", "returning", "a", "user", "object", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L927-L1032
26,820
tornadoweb/tornado
tornado/locks.py
Condition.wait
def wait(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[bool]: """Wait for `.notify`. Returns a `.Future` that resolves ``True`` if the condition is notified, or ``False`` after a timeout. """ waiter = Future() # type: Future[bool] self._waiters.ap...
python
def wait(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[bool]: """Wait for `.notify`. Returns a `.Future` that resolves ``True`` if the condition is notified, or ``False`` after a timeout. """ waiter = Future() # type: Future[bool] self._waiters.ap...
[ "def", "wait", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "bool", "]", ":", "waiter", "=", "Future", "(", ")", "# type: Future[bool]", "self", ".", "_waiter...
Wait for `.notify`. Returns a `.Future` that resolves ``True`` if the condition is notified, or ``False`` after a timeout.
[ "Wait", "for", ".", "notify", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L124-L142
26,821
tornadoweb/tornado
tornado/locks.py
Condition.notify
def notify(self, n: int = 1) -> None: """Wake ``n`` waiters.""" waiters = [] # Waiters we plan to run right now. while n and self._waiters: waiter = self._waiters.popleft() if not waiter.done(): # Might have timed out. n -= 1 waiters.appe...
python
def notify(self, n: int = 1) -> None: """Wake ``n`` waiters.""" waiters = [] # Waiters we plan to run right now. while n and self._waiters: waiter = self._waiters.popleft() if not waiter.done(): # Might have timed out. n -= 1 waiters.appe...
[ "def", "notify", "(", "self", ",", "n", ":", "int", "=", "1", ")", "->", "None", ":", "waiters", "=", "[", "]", "# Waiters we plan to run right now.", "while", "n", "and", "self", ".", "_waiters", ":", "waiter", "=", "self", ".", "_waiters", ".", "popl...
Wake ``n`` waiters.
[ "Wake", "n", "waiters", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L144-L154
26,822
tornadoweb/tornado
tornado/locks.py
Event.set
def set(self) -> None: """Set the internal flag to ``True``. All waiters are awakened. Calling `.wait` once the flag is set will not block. """ if not self._value: self._value = True for fut in self._waiters: if not fut.done(): ...
python
def set(self) -> None: """Set the internal flag to ``True``. All waiters are awakened. Calling `.wait` once the flag is set will not block. """ if not self._value: self._value = True for fut in self._waiters: if not fut.done(): ...
[ "def", "set", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "_value", ":", "self", ".", "_value", "=", "True", "for", "fut", "in", "self", ".", "_waiters", ":", "if", "not", "fut", ".", "done", "(", ")", ":", "fut", ".", "set_r...
Set the internal flag to ``True``. All waiters are awakened. Calling `.wait` once the flag is set will not block.
[ "Set", "the", "internal", "flag", "to", "True", ".", "All", "waiters", "are", "awakened", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L215-L225
26,823
tornadoweb/tornado
tornado/locks.py
Event.wait
def wait(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[None]: """Block until the internal flag is true. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout. """ fut = Future() # type: Future[None] if self._value: ...
python
def wait(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[None]: """Block until the internal flag is true. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout. """ fut = Future() # type: Future[None] if self._value: ...
[ "def", "wait", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "None", "]", ":", "fut", "=", "Future", "(", ")", "# type: Future[None]", "if", "self", ".", "_v...
Block until the internal flag is true. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout.
[ "Block", "until", "the", "internal", "flag", "is", "true", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L234-L258
26,824
tornadoweb/tornado
tornado/locks.py
Semaphore.acquire
def acquire( self, timeout: Union[float, datetime.timedelta] = None ) -> Awaitable[_ReleasingContextManager]: """Decrement the counter. Returns an awaitable. Block if the counter is zero and wait for a `.release`. The awaitable raises `.TimeoutError` after the deadline. """ ...
python
def acquire( self, timeout: Union[float, datetime.timedelta] = None ) -> Awaitable[_ReleasingContextManager]: """Decrement the counter. Returns an awaitable. Block if the counter is zero and wait for a `.release`. The awaitable raises `.TimeoutError` after the deadline. """ ...
[ "def", "acquire", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "_ReleasingContextManager", "]", ":", "waiter", "=", "Future", "(", ")", "# type: Future[_ReleasingCo...
Decrement the counter. Returns an awaitable. Block if the counter is zero and wait for a `.release`. The awaitable raises `.TimeoutError` after the deadline.
[ "Decrement", "the", "counter", ".", "Returns", "an", "awaitable", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L414-L440
26,825
tornadoweb/tornado
tornado/locks.py
Lock.acquire
def acquire( self, timeout: Union[float, datetime.timedelta] = None ) -> Awaitable[_ReleasingContextManager]: """Attempt to lock. Returns an awaitable. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout. """ return self._block.acquire(time...
python
def acquire( self, timeout: Union[float, datetime.timedelta] = None ) -> Awaitable[_ReleasingContextManager]: """Attempt to lock. Returns an awaitable. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout. """ return self._block.acquire(time...
[ "def", "acquire", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "_ReleasingContextManager", "]", ":", "return", "self", ".", "_block", ".", "acquire", "(", "time...
Attempt to lock. Returns an awaitable. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout.
[ "Attempt", "to", "lock", ".", "Returns", "an", "awaitable", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L528-L536
26,826
tornadoweb/tornado
tornado/http1connection.py
HTTP1Connection.read_response
def read_response(self, delegate: httputil.HTTPMessageDelegate) -> Awaitable[bool]: """Read a single HTTP response. Typical client-mode usage is to write a request using `write_headers`, `write`, and `finish`, and then call ``read_response``. :arg delegate: a `.HTTPMessageDelegate` ...
python
def read_response(self, delegate: httputil.HTTPMessageDelegate) -> Awaitable[bool]: """Read a single HTTP response. Typical client-mode usage is to write a request using `write_headers`, `write`, and `finish`, and then call ``read_response``. :arg delegate: a `.HTTPMessageDelegate` ...
[ "def", "read_response", "(", "self", ",", "delegate", ":", "httputil", ".", "HTTPMessageDelegate", ")", "->", "Awaitable", "[", "bool", "]", ":", "if", "self", ".", "params", ".", "decompress", ":", "delegate", "=", "_GzipMessageDelegate", "(", "delegate", "...
Read a single HTTP response. Typical client-mode usage is to write a request using `write_headers`, `write`, and `finish`, and then call ``read_response``. :arg delegate: a `.HTTPMessageDelegate` Returns a `.Future` that resolves to a bool after the full response has been read...
[ "Read", "a", "single", "HTTP", "response", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L165-L178
26,827
tornadoweb/tornado
tornado/http1connection.py
HTTP1Connection._clear_callbacks
def _clear_callbacks(self) -> None: """Clears the callback attributes. This allows the request handler to be garbage collected more quickly in CPython by breaking up reference cycles. """ self._write_callback = None self._write_future = None # type: Optional[Future[None...
python
def _clear_callbacks(self) -> None: """Clears the callback attributes. This allows the request handler to be garbage collected more quickly in CPython by breaking up reference cycles. """ self._write_callback = None self._write_future = None # type: Optional[Future[None...
[ "def", "_clear_callbacks", "(", "self", ")", "->", "None", ":", "self", ".", "_write_callback", "=", "None", "self", ".", "_write_future", "=", "None", "# type: Optional[Future[None]]", "self", ".", "_close_callback", "=", "None", "# type: Optional[Callable[[], None]]...
Clears the callback attributes. This allows the request handler to be garbage collected more quickly in CPython by breaking up reference cycles.
[ "Clears", "the", "callback", "attributes", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L302-L312
26,828
tornadoweb/tornado
tornado/http1connection.py
HTTP1Connection.write_headers
def write_headers( self, start_line: Union[httputil.RequestStartLine, httputil.ResponseStartLine], headers: httputil.HTTPHeaders, chunk: bytes = None, ) -> "Future[None]": """Implements `.HTTPConnection.write_headers`.""" lines = [] if self.is_client: ...
python
def write_headers( self, start_line: Union[httputil.RequestStartLine, httputil.ResponseStartLine], headers: httputil.HTTPHeaders, chunk: bytes = None, ) -> "Future[None]": """Implements `.HTTPConnection.write_headers`.""" lines = [] if self.is_client: ...
[ "def", "write_headers", "(", "self", ",", "start_line", ":", "Union", "[", "httputil", ".", "RequestStartLine", ",", "httputil", ".", "ResponseStartLine", "]", ",", "headers", ":", "httputil", ".", "HTTPHeaders", ",", "chunk", ":", "bytes", "=", "None", ",",...
Implements `.HTTPConnection.write_headers`.
[ "Implements", ".", "HTTPConnection", ".", "write_headers", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L376-L465
26,829
tornadoweb/tornado
tornado/http1connection.py
HTTP1Connection.write
def write(self, chunk: bytes) -> "Future[None]": """Implements `.HTTPConnection.write`. For backwards compatibility it is allowed but deprecated to skip `write_headers` and instead call `write()` with a pre-encoded header block. """ future = None if self.stream.c...
python
def write(self, chunk: bytes) -> "Future[None]": """Implements `.HTTPConnection.write`. For backwards compatibility it is allowed but deprecated to skip `write_headers` and instead call `write()` with a pre-encoded header block. """ future = None if self.stream.c...
[ "def", "write", "(", "self", ",", "chunk", ":", "bytes", ")", "->", "\"Future[None]\"", ":", "future", "=", "None", "if", "self", ".", "stream", ".", "closed", "(", ")", ":", "future", "=", "self", ".", "_write_future", "=", "Future", "(", ")", "self...
Implements `.HTTPConnection.write`. For backwards compatibility it is allowed but deprecated to skip `write_headers` and instead call `write()` with a pre-encoded header block.
[ "Implements", ".", "HTTPConnection", ".", "write", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L483-L499
26,830
tornadoweb/tornado
tornado/http1connection.py
HTTP1Connection.finish
def finish(self) -> None: """Implements `.HTTPConnection.finish`.""" if ( self._expected_content_remaining is not None and self._expected_content_remaining != 0 and not self.stream.closed() ): self.stream.close() raise httputil.HTTPOutp...
python
def finish(self) -> None: """Implements `.HTTPConnection.finish`.""" if ( self._expected_content_remaining is not None and self._expected_content_remaining != 0 and not self.stream.closed() ): self.stream.close() raise httputil.HTTPOutp...
[ "def", "finish", "(", "self", ")", "->", "None", ":", "if", "(", "self", ".", "_expected_content_remaining", "is", "not", "None", "and", "self", ".", "_expected_content_remaining", "!=", "0", "and", "not", "self", ".", "stream", ".", "closed", "(", ")", ...
Implements `.HTTPConnection.finish`.
[ "Implements", ".", "HTTPConnection", ".", "finish", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L501-L531
26,831
tornadoweb/tornado
tornado/http1connection.py
HTTP1ServerConnection.start_serving
def start_serving(self, delegate: httputil.HTTPServerConnectionDelegate) -> None: """Starts serving requests on this connection. :arg delegate: a `.HTTPServerConnectionDelegate` """ assert isinstance(delegate, httputil.HTTPServerConnectionDelegate) fut = gen.convert_yielded(self...
python
def start_serving(self, delegate: httputil.HTTPServerConnectionDelegate) -> None: """Starts serving requests on this connection. :arg delegate: a `.HTTPServerConnectionDelegate` """ assert isinstance(delegate, httputil.HTTPServerConnectionDelegate) fut = gen.convert_yielded(self...
[ "def", "start_serving", "(", "self", ",", "delegate", ":", "httputil", ".", "HTTPServerConnectionDelegate", ")", "->", "None", ":", "assert", "isinstance", "(", "delegate", ",", "httputil", ".", "HTTPServerConnectionDelegate", ")", "fut", "=", "gen", ".", "conve...
Starts serving requests on this connection. :arg delegate: a `.HTTPServerConnectionDelegate`
[ "Starts", "serving", "requests", "on", "this", "connection", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L798-L807
26,832
tornadoweb/tornado
tornado/websocket.py
websocket_connect
def websocket_connect( url: Union[str, httpclient.HTTPRequest], callback: Callable[["Future[WebSocketClientConnection]"], None] = None, connect_timeout: float = None, on_message_callback: Callable[[Union[None, str, bytes]], None] = None, compression_options: Dict[str, Any] = None, ping_interval:...
python
def websocket_connect( url: Union[str, httpclient.HTTPRequest], callback: Callable[["Future[WebSocketClientConnection]"], None] = None, connect_timeout: float = None, on_message_callback: Callable[[Union[None, str, bytes]], None] = None, compression_options: Dict[str, Any] = None, ping_interval:...
[ "def", "websocket_connect", "(", "url", ":", "Union", "[", "str", ",", "httpclient", ".", "HTTPRequest", "]", ",", "callback", ":", "Callable", "[", "[", "\"Future[WebSocketClientConnection]\"", "]", ",", "None", "]", "=", "None", ",", "connect_timeout", ":", ...
Client-side websocket support. Takes a url and returns a Future whose result is a `WebSocketClientConnection`. ``compression_options`` is interpreted in the same way as the return value of `.WebSocketHandler.get_compression_options`. The connection supports two styles of operation. In the corouti...
[ "Client", "-", "side", "websocket", "support", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1586-L1663
26,833
tornadoweb/tornado
tornado/websocket.py
WebSocketHandler.close
def close(self, code: int = None, reason: str = None) -> None: """Closes this Web Socket. Once the close handshake is successful the socket will be closed. ``code`` may be a numeric status code, taken from the values defined in `RFC 6455 section 7.4.1 <https://tools.ietf.org/ht...
python
def close(self, code: int = None, reason: str = None) -> None: """Closes this Web Socket. Once the close handshake is successful the socket will be closed. ``code`` may be a numeric status code, taken from the values defined in `RFC 6455 section 7.4.1 <https://tools.ietf.org/ht...
[ "def", "close", "(", "self", ",", "code", ":", "int", "=", "None", ",", "reason", ":", "str", "=", "None", ")", "->", "None", ":", "if", "self", ".", "ws_connection", ":", "self", ".", "ws_connection", ".", "close", "(", "code", ",", "reason", ")",...
Closes this Web Socket. Once the close handshake is successful the socket will be closed. ``code`` may be a numeric status code, taken from the values defined in `RFC 6455 section 7.4.1 <https://tools.ietf.org/html/rfc6455#section-7.4.1>`_. ``reason`` may be a textual message a...
[ "Closes", "this", "Web", "Socket", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L471-L489
26,834
tornadoweb/tornado
tornado/websocket.py
WebSocketHandler.check_origin
def check_origin(self, origin: str) -> bool: """Override to enable support for allowing alternate origins. The ``origin`` argument is the value of the ``Origin`` HTTP header, the url responsible for initiating this request. This method is not called for clients that do not send this he...
python
def check_origin(self, origin: str) -> bool: """Override to enable support for allowing alternate origins. The ``origin`` argument is the value of the ``Origin`` HTTP header, the url responsible for initiating this request. This method is not called for clients that do not send this he...
[ "def", "check_origin", "(", "self", ",", "origin", ":", "str", ")", "->", "bool", ":", "parsed_origin", "=", "urlparse", "(", "origin", ")", "origin", "=", "parsed_origin", ".", "netloc", "origin", "=", "origin", ".", "lower", "(", ")", "host", "=", "s...
Override to enable support for allowing alternate origins. The ``origin`` argument is the value of the ``Origin`` HTTP header, the url responsible for initiating this request. This method is not called for clients that do not send this header; such requests are always allowed (because ...
[ "Override", "to", "enable", "support", "for", "allowing", "alternate", "origins", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L491-L545
26,835
tornadoweb/tornado
tornado/websocket.py
WebSocketHandler.set_nodelay
def set_nodelay(self, value: bool) -> None: """Set the no-delay flag for this stream. By default, small messages may be delayed and/or combined to minimize the number of packets sent. This can sometimes cause 200-500ms delays due to the interaction between Nagle's algorithm and TCP del...
python
def set_nodelay(self, value: bool) -> None: """Set the no-delay flag for this stream. By default, small messages may be delayed and/or combined to minimize the number of packets sent. This can sometimes cause 200-500ms delays due to the interaction between Nagle's algorithm and TCP del...
[ "def", "set_nodelay", "(", "self", ",", "value", ":", "bool", ")", "->", "None", ":", "assert", "self", ".", "ws_connection", "is", "not", "None", "self", ".", "ws_connection", ".", "set_nodelay", "(", "value", ")" ]
Set the no-delay flag for this stream. By default, small messages may be delayed and/or combined to minimize the number of packets sent. This can sometimes cause 200-500ms delays due to the interaction between Nagle's algorithm and TCP delayed ACKs. To reduce this delay (at the expens...
[ "Set", "the", "no", "-", "delay", "flag", "for", "this", "stream", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L547-L562
26,836
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol._run_callback
def _run_callback( self, callback: Callable, *args: Any, **kwargs: Any ) -> "Optional[Future[Any]]": """Runs the given callback with exception handling. If the callback is a coroutine, returns its Future. On error, aborts the websocket connection and returns None. """ ...
python
def _run_callback( self, callback: Callable, *args: Any, **kwargs: Any ) -> "Optional[Future[Any]]": """Runs the given callback with exception handling. If the callback is a coroutine, returns its Future. On error, aborts the websocket connection and returns None. """ ...
[ "def", "_run_callback", "(", "self", ",", "callback", ":", "Callable", ",", "*", "args", ":", "Any", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "\"Optional[Future[Any]]\"", ":", "try", ":", "result", "=", "callback", "(", "*", "args", ",", "*", ...
Runs the given callback with exception handling. If the callback is a coroutine, returns its Future. On error, aborts the websocket connection and returns None.
[ "Runs", "the", "given", "callback", "with", "exception", "handling", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L640-L659
26,837
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol._abort
def _abort(self) -> None: """Instantly aborts the WebSocket connection by closing the socket""" self.client_terminated = True self.server_terminated = True if self.stream is not None: self.stream.close() # forcibly tear down the connection self.close()
python
def _abort(self) -> None: """Instantly aborts the WebSocket connection by closing the socket""" self.client_terminated = True self.server_terminated = True if self.stream is not None: self.stream.close() # forcibly tear down the connection self.close()
[ "def", "_abort", "(", "self", ")", "->", "None", ":", "self", ".", "client_terminated", "=", "True", "self", ".", "server_terminated", "=", "True", "if", "self", ".", "stream", "is", "not", "None", ":", "self", ".", "stream", ".", "close", "(", ")", ...
Instantly aborts the WebSocket connection by closing the socket
[ "Instantly", "aborts", "the", "WebSocket", "connection", "by", "closing", "the", "socket" ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L664-L670
26,838
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13._handle_websocket_headers
def _handle_websocket_headers(self, handler: WebSocketHandler) -> None: """Verifies all invariant- and required headers If a header is missing or have an incorrect value ValueError will be raised """ fields = ("Host", "Sec-Websocket-Key", "Sec-Websocket-Version") if not ...
python
def _handle_websocket_headers(self, handler: WebSocketHandler) -> None: """Verifies all invariant- and required headers If a header is missing or have an incorrect value ValueError will be raised """ fields = ("Host", "Sec-Websocket-Key", "Sec-Websocket-Version") if not ...
[ "def", "_handle_websocket_headers", "(", "self", ",", "handler", ":", "WebSocketHandler", ")", "->", "None", ":", "fields", "=", "(", "\"Host\"", ",", "\"Sec-Websocket-Key\"", ",", "\"Sec-Websocket-Version\"", ")", "if", "not", "all", "(", "map", "(", "lambda", ...
Verifies all invariant- and required headers If a header is missing or have an incorrect value ValueError will be raised
[ "Verifies", "all", "invariant", "-", "and", "required", "headers" ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L890-L898
26,839
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13.compute_accept_value
def compute_accept_value(key: Union[str, bytes]) -> str: """Computes the value for the Sec-WebSocket-Accept header, given the value for Sec-WebSocket-Key. """ sha1 = hashlib.sha1() sha1.update(utf8(key)) sha1.update(b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11") # Magic value ...
python
def compute_accept_value(key: Union[str, bytes]) -> str: """Computes the value for the Sec-WebSocket-Accept header, given the value for Sec-WebSocket-Key. """ sha1 = hashlib.sha1() sha1.update(utf8(key)) sha1.update(b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11") # Magic value ...
[ "def", "compute_accept_value", "(", "key", ":", "Union", "[", "str", ",", "bytes", "]", ")", "->", "str", ":", "sha1", "=", "hashlib", ".", "sha1", "(", ")", "sha1", ".", "update", "(", "utf8", "(", "key", ")", ")", "sha1", ".", "update", "(", "b...
Computes the value for the Sec-WebSocket-Accept header, given the value for Sec-WebSocket-Key.
[ "Computes", "the", "value", "for", "the", "Sec", "-", "WebSocket", "-", "Accept", "header", "given", "the", "value", "for", "Sec", "-", "WebSocket", "-", "Key", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L901-L908
26,840
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13._process_server_headers
def _process_server_headers( self, key: Union[str, bytes], headers: httputil.HTTPHeaders ) -> None: """Process the headers sent by the server to this client connection. 'key' is the websocket handshake challenge/response key. """ assert headers["Upgrade"].lower() == "websock...
python
def _process_server_headers( self, key: Union[str, bytes], headers: httputil.HTTPHeaders ) -> None: """Process the headers sent by the server to this client connection. 'key' is the websocket handshake challenge/response key. """ assert headers["Upgrade"].lower() == "websock...
[ "def", "_process_server_headers", "(", "self", ",", "key", ":", "Union", "[", "str", ",", "bytes", "]", ",", "headers", ":", "httputil", ".", "HTTPHeaders", ")", "->", "None", ":", "assert", "headers", "[", "\"Upgrade\"", "]", ".", "lower", "(", ")", "...
Process the headers sent by the server to this client connection. 'key' is the websocket handshake challenge/response key.
[ "Process", "the", "headers", "sent", "by", "the", "server", "to", "this", "client", "connection", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L974-L993
26,841
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13._get_compressor_options
def _get_compressor_options( self, side: str, agreed_parameters: Dict[str, Any], compression_options: Dict[str, Any] = None, ) -> Dict[str, Any]: """Converts a websocket agreed_parameters set to keyword arguments for our compressor objects. """ options...
python
def _get_compressor_options( self, side: str, agreed_parameters: Dict[str, Any], compression_options: Dict[str, Any] = None, ) -> Dict[str, Any]: """Converts a websocket agreed_parameters set to keyword arguments for our compressor objects. """ options...
[ "def", "_get_compressor_options", "(", "self", ",", "side", ":", "str", ",", "agreed_parameters", ":", "Dict", "[", "str", ",", "Any", "]", ",", "compression_options", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ",", ")", "->", "Dict", "[", ...
Converts a websocket agreed_parameters set to keyword arguments for our compressor objects.
[ "Converts", "a", "websocket", "agreed_parameters", "set", "to", "keyword", "arguments", "for", "our", "compressor", "objects", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L995-L1013
26,842
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13.write_ping
def write_ping(self, data: bytes) -> None: """Send ping frame.""" assert isinstance(data, bytes) self._write_frame(True, 0x9, data)
python
def write_ping(self, data: bytes) -> None: """Send ping frame.""" assert isinstance(data, bytes) self._write_frame(True, 0x9, data)
[ "def", "write_ping", "(", "self", ",", "data", ":", "bytes", ")", "->", "None", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "self", ".", "_write_frame", "(", "True", ",", "0x9", ",", "data", ")" ]
Send ping frame.
[ "Send", "ping", "frame", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1110-L1113
26,843
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13._handle_message
def _handle_message(self, opcode: int, data: bytes) -> "Optional[Future[None]]": """Execute on_message, returning its Future if it is a coroutine.""" if self.client_terminated: return None if self._frame_compressed: assert self._decompressor is not None try: ...
python
def _handle_message(self, opcode: int, data: bytes) -> "Optional[Future[None]]": """Execute on_message, returning its Future if it is a coroutine.""" if self.client_terminated: return None if self._frame_compressed: assert self._decompressor is not None try: ...
[ "def", "_handle_message", "(", "self", ",", "opcode", ":", "int", ",", "data", ":", "bytes", ")", "->", "\"Optional[Future[None]]\"", ":", "if", "self", ".", "client_terminated", ":", "return", "None", "if", "self", ".", "_frame_compressed", ":", "assert", "...
Execute on_message, returning its Future if it is a coroutine.
[ "Execute", "on_message", "returning", "its", "Future", "if", "it", "is", "a", "coroutine", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1211-L1260
26,844
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13.close
def close(self, code: int = None, reason: str = None) -> None: """Closes the WebSocket connection.""" if not self.server_terminated: if not self.stream.closed(): if code is None and reason is not None: code = 1000 # "normal closure" status code ...
python
def close(self, code: int = None, reason: str = None) -> None: """Closes the WebSocket connection.""" if not self.server_terminated: if not self.stream.closed(): if code is None and reason is not None: code = 1000 # "normal closure" status code ...
[ "def", "close", "(", "self", ",", "code", ":", "int", "=", "None", ",", "reason", ":", "str", "=", "None", ")", "->", "None", ":", "if", "not", "self", ".", "server_terminated", ":", "if", "not", "self", ".", "stream", ".", "closed", "(", ")", ":...
Closes the WebSocket connection.
[ "Closes", "the", "WebSocket", "connection", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1262-L1289
26,845
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13.is_closing
def is_closing(self) -> bool: """Return ``True`` if this connection is closing. The connection is considered closing if either side has initiated its closing handshake or if the stream has been shut down uncleanly. """ return self.stream.closed() or self.client_terminate...
python
def is_closing(self) -> bool: """Return ``True`` if this connection is closing. The connection is considered closing if either side has initiated its closing handshake or if the stream has been shut down uncleanly. """ return self.stream.closed() or self.client_terminate...
[ "def", "is_closing", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "stream", ".", "closed", "(", ")", "or", "self", ".", "client_terminated", "or", "self", ".", "server_terminated" ]
Return ``True`` if this connection is closing. The connection is considered closing if either side has initiated its closing handshake or if the stream has been shut down uncleanly.
[ "Return", "True", "if", "this", "connection", "is", "closing", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1291-L1298
26,846
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13.start_pinging
def start_pinging(self) -> None: """Start sending periodic pings to keep the connection alive""" assert self.ping_interval is not None if self.ping_interval > 0: self.last_ping = self.last_pong = IOLoop.current().time() self.ping_callback = PeriodicCallback( ...
python
def start_pinging(self) -> None: """Start sending periodic pings to keep the connection alive""" assert self.ping_interval is not None if self.ping_interval > 0: self.last_ping = self.last_pong = IOLoop.current().time() self.ping_callback = PeriodicCallback( ...
[ "def", "start_pinging", "(", "self", ")", "->", "None", ":", "assert", "self", ".", "ping_interval", "is", "not", "None", "if", "self", ".", "ping_interval", ">", "0", ":", "self", ".", "last_ping", "=", "self", ".", "last_pong", "=", "IOLoop", ".", "c...
Start sending periodic pings to keep the connection alive
[ "Start", "sending", "periodic", "pings", "to", "keep", "the", "connection", "alive" ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1315-L1323
26,847
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13.periodic_ping
def periodic_ping(self) -> None: """Send a ping to keep the websocket alive Called periodically if the websocket_ping_interval is set and non-zero. """ if self.is_closing() and self.ping_callback is not None: self.ping_callback.stop() return # Check for ...
python
def periodic_ping(self) -> None: """Send a ping to keep the websocket alive Called periodically if the websocket_ping_interval is set and non-zero. """ if self.is_closing() and self.ping_callback is not None: self.ping_callback.stop() return # Check for ...
[ "def", "periodic_ping", "(", "self", ")", "->", "None", ":", "if", "self", ".", "is_closing", "(", ")", "and", "self", ".", "ping_callback", "is", "not", "None", ":", "self", ".", "ping_callback", ".", "stop", "(", ")", "return", "# Check for timeout on po...
Send a ping to keep the websocket alive Called periodically if the websocket_ping_interval is set and non-zero.
[ "Send", "a", "ping", "to", "keep", "the", "websocket", "alive" ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1325-L1350
26,848
tornadoweb/tornado
tornado/websocket.py
WebSocketClientConnection.write_message
def write_message( self, message: Union[str, bytes], binary: bool = False ) -> "Future[None]": """Sends a message to the WebSocket server. If the stream is closed, raises `WebSocketClosedError`. Returns a `.Future` which can be used for flow control. .. versionchanged:: 5.0...
python
def write_message( self, message: Union[str, bytes], binary: bool = False ) -> "Future[None]": """Sends a message to the WebSocket server. If the stream is closed, raises `WebSocketClosedError`. Returns a `.Future` which can be used for flow control. .. versionchanged:: 5.0...
[ "def", "write_message", "(", "self", ",", "message", ":", "Union", "[", "str", ",", "bytes", "]", ",", "binary", ":", "bool", "=", "False", ")", "->", "\"Future[None]\"", ":", "return", "self", ".", "protocol", ".", "write_message", "(", "message", ",", ...
Sends a message to the WebSocket server. If the stream is closed, raises `WebSocketClosedError`. Returns a `.Future` which can be used for flow control. .. versionchanged:: 5.0 Exception raised on a closed stream changed from `.StreamClosedError` to `WebSocketClosedError`...
[ "Sends", "a", "message", "to", "the", "WebSocket", "server", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1494-L1506
26,849
tornadoweb/tornado
tornado/websocket.py
WebSocketClientConnection.read_message
def read_message( self, callback: Callable[["Future[Union[None, str, bytes]]"], None] = None ) -> Awaitable[Union[None, str, bytes]]: """Reads a message from the WebSocket server. If on_message_callback was specified at WebSocket initialization, this function will never return messa...
python
def read_message( self, callback: Callable[["Future[Union[None, str, bytes]]"], None] = None ) -> Awaitable[Union[None, str, bytes]]: """Reads a message from the WebSocket server. If on_message_callback was specified at WebSocket initialization, this function will never return messa...
[ "def", "read_message", "(", "self", ",", "callback", ":", "Callable", "[", "[", "\"Future[Union[None, str, bytes]]\"", "]", ",", "None", "]", "=", "None", ")", "->", "Awaitable", "[", "Union", "[", "None", ",", "str", ",", "bytes", "]", "]", ":", "awaita...
Reads a message from the WebSocket server. If on_message_callback was specified at WebSocket initialization, this function will never return messages Returns a future whose result is the message, or None if the connection is closed. If a callback argument is given it will be c...
[ "Reads", "a", "message", "from", "the", "WebSocket", "server", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1508-L1525
26,850
tornadoweb/tornado
tornado/options.py
define
def define( name: str, default: Any = None, type: type = None, help: str = None, metavar: str = None, multiple: bool = False, group: str = None, callback: Callable[[Any], None] = None, ) -> None: """Defines an option in the global namespace. See `OptionParser.define`. """ ...
python
def define( name: str, default: Any = None, type: type = None, help: str = None, metavar: str = None, multiple: bool = False, group: str = None, callback: Callable[[Any], None] = None, ) -> None: """Defines an option in the global namespace. See `OptionParser.define`. """ ...
[ "def", "define", "(", "name", ":", "str", ",", "default", ":", "Any", "=", "None", ",", "type", ":", "type", "=", "None", ",", "help", ":", "str", "=", "None", ",", "metavar", ":", "str", "=", "None", ",", "multiple", ":", "bool", "=", "False", ...
Defines an option in the global namespace. See `OptionParser.define`.
[ "Defines", "an", "option", "in", "the", "global", "namespace", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L667-L690
26,851
tornadoweb/tornado
tornado/options.py
parse_command_line
def parse_command_line(args: List[str] = None, final: bool = True) -> List[str]: """Parses global options from the command line. See `OptionParser.parse_command_line`. """ return options.parse_command_line(args, final=final)
python
def parse_command_line(args: List[str] = None, final: bool = True) -> List[str]: """Parses global options from the command line. See `OptionParser.parse_command_line`. """ return options.parse_command_line(args, final=final)
[ "def", "parse_command_line", "(", "args", ":", "List", "[", "str", "]", "=", "None", ",", "final", ":", "bool", "=", "True", ")", "->", "List", "[", "str", "]", ":", "return", "options", ".", "parse_command_line", "(", "args", ",", "final", "=", "fin...
Parses global options from the command line. See `OptionParser.parse_command_line`.
[ "Parses", "global", "options", "from", "the", "command", "line", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L693-L698
26,852
tornadoweb/tornado
tornado/options.py
parse_config_file
def parse_config_file(path: str, final: bool = True) -> None: """Parses global options from a config file. See `OptionParser.parse_config_file`. """ return options.parse_config_file(path, final=final)
python
def parse_config_file(path: str, final: bool = True) -> None: """Parses global options from a config file. See `OptionParser.parse_config_file`. """ return options.parse_config_file(path, final=final)
[ "def", "parse_config_file", "(", "path", ":", "str", ",", "final", ":", "bool", "=", "True", ")", "->", "None", ":", "return", "options", ".", "parse_config_file", "(", "path", ",", "final", "=", "final", ")" ]
Parses global options from a config file. See `OptionParser.parse_config_file`.
[ "Parses", "global", "options", "from", "a", "config", "file", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L701-L706
26,853
tornadoweb/tornado
tornado/options.py
OptionParser.groups
def groups(self) -> Set[str]: """The set of option-groups created by ``define``. .. versionadded:: 3.1 """ return set(opt.group_name for opt in self._options.values())
python
def groups(self) -> Set[str]: """The set of option-groups created by ``define``. .. versionadded:: 3.1 """ return set(opt.group_name for opt in self._options.values())
[ "def", "groups", "(", "self", ")", "->", "Set", "[", "str", "]", ":", "return", "set", "(", "opt", ".", "group_name", "for", "opt", "in", "self", ".", "_options", ".", "values", "(", ")", ")" ]
The set of option-groups created by ``define``. .. versionadded:: 3.1
[ "The", "set", "of", "option", "-", "groups", "created", "by", "define", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L173-L178
26,854
tornadoweb/tornado
tornado/options.py
OptionParser.group_dict
def group_dict(self, group: str) -> Dict[str, Any]: """The names and values of options in a group. Useful for copying options into Application settings:: from tornado.options import define, parse_command_line, options define('template_path', group='application') de...
python
def group_dict(self, group: str) -> Dict[str, Any]: """The names and values of options in a group. Useful for copying options into Application settings:: from tornado.options import define, parse_command_line, options define('template_path', group='application') de...
[ "def", "group_dict", "(", "self", ",", "group", ":", "str", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "dict", "(", "(", "opt", ".", "name", ",", "opt", ".", "value", "(", ")", ")", "for", "name", ",", "opt", "in", "self", ...
The names and values of options in a group. Useful for copying options into Application settings:: from tornado.options import define, parse_command_line, options define('template_path', group='application') define('static_path', group='application') parse_com...
[ "The", "names", "and", "values", "of", "options", "in", "a", "group", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L180-L201
26,855
tornadoweb/tornado
tornado/options.py
OptionParser.as_dict
def as_dict(self) -> Dict[str, Any]: """The names and values of all options. .. versionadded:: 3.1 """ return dict((opt.name, opt.value()) for name, opt in self._options.items())
python
def as_dict(self) -> Dict[str, Any]: """The names and values of all options. .. versionadded:: 3.1 """ return dict((opt.name, opt.value()) for name, opt in self._options.items())
[ "def", "as_dict", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "dict", "(", "(", "opt", ".", "name", ",", "opt", ".", "value", "(", ")", ")", "for", "name", ",", "opt", "in", "self", ".", "_options", ".", "items",...
The names and values of all options. .. versionadded:: 3.1
[ "The", "names", "and", "values", "of", "all", "options", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L203-L208
26,856
tornadoweb/tornado
tornado/options.py
OptionParser.define
def define( self, name: str, default: Any = None, type: type = None, help: str = None, metavar: str = None, multiple: bool = False, group: str = None, callback: Callable[[Any], None] = None, ) -> None: """Defines a new command line opti...
python
def define( self, name: str, default: Any = None, type: type = None, help: str = None, metavar: str = None, multiple: bool = False, group: str = None, callback: Callable[[Any], None] = None, ) -> None: """Defines a new command line opti...
[ "def", "define", "(", "self", ",", "name", ":", "str", ",", "default", ":", "Any", "=", "None", ",", "type", ":", "type", "=", "None", ",", "help", ":", "str", "=", "None", ",", "metavar", ":", "str", "=", "None", ",", "multiple", ":", "bool", ...
Defines a new command line option. ``type`` can be any of `str`, `int`, `float`, `bool`, `~datetime.datetime`, or `~datetime.timedelta`. If no ``type`` is given but a ``default`` is, ``type`` is the type of ``default``. Otherwise, ``type`` defaults to `str`. If ``multiple`` is ...
[ "Defines", "a", "new", "command", "line", "option", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L210-L295
26,857
tornadoweb/tornado
tornado/options.py
OptionParser.parse_config_file
def parse_config_file(self, path: str, final: bool = True) -> None: """Parses and loads the config file at the given path. The config file contains Python code that will be executed (so it is **not safe** to use untrusted config files). Anything in the global namespace that matches a de...
python
def parse_config_file(self, path: str, final: bool = True) -> None: """Parses and loads the config file at the given path. The config file contains Python code that will be executed (so it is **not safe** to use untrusted config files). Anything in the global namespace that matches a de...
[ "def", "parse_config_file", "(", "self", ",", "path", ":", "str", ",", "final", ":", "bool", "=", "True", ")", "->", "None", ":", "config", "=", "{", "\"__file__\"", ":", "os", ".", "path", ".", "abspath", "(", "path", ")", "}", "with", "open", "("...
Parses and loads the config file at the given path. The config file contains Python code that will be executed (so it is **not safe** to use untrusted config files). Anything in the global namespace that matches a defined option will be used to set that option's value. Options ...
[ "Parses", "and", "loads", "the", "config", "file", "at", "the", "given", "path", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L351-L418
26,858
tornadoweb/tornado
demos/blog/blog.py
BaseHandler.row_to_obj
def row_to_obj(self, row, cur): """Convert a SQL row to an object supporting dict and attribute access.""" obj = tornado.util.ObjectDict() for val, desc in zip(row, cur.description): obj[desc.name] = val return obj
python
def row_to_obj(self, row, cur): """Convert a SQL row to an object supporting dict and attribute access.""" obj = tornado.util.ObjectDict() for val, desc in zip(row, cur.description): obj[desc.name] = val return obj
[ "def", "row_to_obj", "(", "self", ",", "row", ",", "cur", ")", ":", "obj", "=", "tornado", ".", "util", ".", "ObjectDict", "(", ")", "for", "val", ",", "desc", "in", "zip", "(", "row", ",", "cur", ".", "description", ")", ":", "obj", "[", "desc",...
Convert a SQL row to an object supporting dict and attribute access.
[ "Convert", "a", "SQL", "row", "to", "an", "object", "supporting", "dict", "and", "attribute", "access", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/demos/blog/blog.py#L84-L89
26,859
tornadoweb/tornado
demos/blog/blog.py
BaseHandler.query
async def query(self, stmt, *args): """Query for a list of results. Typical usage:: results = await self.query(...) Or:: for row in await self.query(...) """ with (await self.application.db.cursor()) as cur: await cur.execute(stmt, args) ...
python
async def query(self, stmt, *args): """Query for a list of results. Typical usage:: results = await self.query(...) Or:: for row in await self.query(...) """ with (await self.application.db.cursor()) as cur: await cur.execute(stmt, args) ...
[ "async", "def", "query", "(", "self", ",", "stmt", ",", "*", "args", ")", ":", "with", "(", "await", "self", ".", "application", ".", "db", ".", "cursor", "(", ")", ")", "as", "cur", ":", "await", "cur", ".", "execute", "(", "stmt", ",", "args", ...
Query for a list of results. Typical usage:: results = await self.query(...) Or:: for row in await self.query(...)
[ "Query", "for", "a", "list", "of", "results", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/demos/blog/blog.py#L99-L112
26,860
tornadoweb/tornado
demos/blog/blog.py
BaseHandler.queryone
async def queryone(self, stmt, *args): """Query for exactly one result. Raises NoResultError if there are no results, or ValueError if there are more than one. """ results = await self.query(stmt, *args) if len(results) == 0: raise NoResultError() eli...
python
async def queryone(self, stmt, *args): """Query for exactly one result. Raises NoResultError if there are no results, or ValueError if there are more than one. """ results = await self.query(stmt, *args) if len(results) == 0: raise NoResultError() eli...
[ "async", "def", "queryone", "(", "self", ",", "stmt", ",", "*", "args", ")", ":", "results", "=", "await", "self", ".", "query", "(", "stmt", ",", "*", "args", ")", "if", "len", "(", "results", ")", "==", "0", ":", "raise", "NoResultError", "(", ...
Query for exactly one result. Raises NoResultError if there are no results, or ValueError if there are more than one.
[ "Query", "for", "exactly", "one", "result", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/demos/blog/blog.py#L114-L125
26,861
tornadoweb/tornado
tornado/tcpserver.py
TCPServer.listen
def listen(self, port: int, address: str = "") -> None: """Starts accepting connections on the given port. This method may be called more than once to listen on multiple ports. `listen` takes effect immediately; it is not necessary to call `TCPServer.start` afterwards. It is, however, ...
python
def listen(self, port: int, address: str = "") -> None: """Starts accepting connections on the given port. This method may be called more than once to listen on multiple ports. `listen` takes effect immediately; it is not necessary to call `TCPServer.start` afterwards. It is, however, ...
[ "def", "listen", "(", "self", ",", "port", ":", "int", ",", "address", ":", "str", "=", "\"\"", ")", "->", "None", ":", "sockets", "=", "bind_sockets", "(", "port", ",", "address", "=", "address", ")", "self", ".", "add_sockets", "(", "sockets", ")" ...
Starts accepting connections on the given port. This method may be called more than once to listen on multiple ports. `listen` takes effect immediately; it is not necessary to call `TCPServer.start` afterwards. It is, however, necessary to start the `.IOLoop`.
[ "Starts", "accepting", "connections", "on", "the", "given", "port", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpserver.py#L143-L152
26,862
tornadoweb/tornado
tornado/tcpserver.py
TCPServer.add_sockets
def add_sockets(self, sockets: Iterable[socket.socket]) -> None: """Makes this server start accepting connections on the given sockets. The ``sockets`` parameter is a list of socket objects such as those returned by `~tornado.netutil.bind_sockets`. `add_sockets` is typically used in com...
python
def add_sockets(self, sockets: Iterable[socket.socket]) -> None: """Makes this server start accepting connections on the given sockets. The ``sockets`` parameter is a list of socket objects such as those returned by `~tornado.netutil.bind_sockets`. `add_sockets` is typically used in com...
[ "def", "add_sockets", "(", "self", ",", "sockets", ":", "Iterable", "[", "socket", ".", "socket", "]", ")", "->", "None", ":", "for", "sock", "in", "sockets", ":", "self", ".", "_sockets", "[", "sock", ".", "fileno", "(", ")", "]", "=", "sock", "se...
Makes this server start accepting connections on the given sockets. The ``sockets`` parameter is a list of socket objects such as those returned by `~tornado.netutil.bind_sockets`. `add_sockets` is typically used in combination with that method and `tornado.process.fork_processes` to pr...
[ "Makes", "this", "server", "start", "accepting", "connections", "on", "the", "given", "sockets", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpserver.py#L154-L167
26,863
tornadoweb/tornado
tornado/tcpserver.py
TCPServer.bind
def bind( self, port: int, address: str = None, family: socket.AddressFamily = socket.AF_UNSPEC, backlog: int = 128, reuse_port: bool = False, ) -> None: """Binds this server to the given port on the given address. To start the server, call `start`. I...
python
def bind( self, port: int, address: str = None, family: socket.AddressFamily = socket.AF_UNSPEC, backlog: int = 128, reuse_port: bool = False, ) -> None: """Binds this server to the given port on the given address. To start the server, call `start`. I...
[ "def", "bind", "(", "self", ",", "port", ":", "int", ",", "address", ":", "str", "=", "None", ",", "family", ":", "socket", ".", "AddressFamily", "=", "socket", ".", "AF_UNSPEC", ",", "backlog", ":", "int", "=", "128", ",", "reuse_port", ":", "bool",...
Binds this server to the given port on the given address. To start the server, call `start`. If you want to run this server in a single process, you can call `listen` as a shortcut to the sequence of `bind` and `start` calls. Address may be either an IP address or hostname. If it's a ...
[ "Binds", "this", "server", "to", "the", "given", "port", "on", "the", "given", "address", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpserver.py#L173-L210
26,864
tornadoweb/tornado
tornado/tcpserver.py
TCPServer.start
def start(self, num_processes: Optional[int] = 1, max_restarts: int = None) -> None: """Starts this server in the `.IOLoop`. By default, we run the server in this process and do not fork any additional child process. If num_processes is ``None`` or <= 0, we detect the number of cores ...
python
def start(self, num_processes: Optional[int] = 1, max_restarts: int = None) -> None: """Starts this server in the `.IOLoop`. By default, we run the server in this process and do not fork any additional child process. If num_processes is ``None`` or <= 0, we detect the number of cores ...
[ "def", "start", "(", "self", ",", "num_processes", ":", "Optional", "[", "int", "]", "=", "1", ",", "max_restarts", ":", "int", "=", "None", ")", "->", "None", ":", "assert", "not", "self", ".", "_started", "self", ".", "_started", "=", "True", "if",...
Starts this server in the `.IOLoop`. By default, we run the server in this process and do not fork any additional child process. If num_processes is ``None`` or <= 0, we detect the number of cores available on this machine and fork that number of child processes. If num_process...
[ "Starts", "this", "server", "in", "the", ".", "IOLoop", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpserver.py#L212-L246
26,865
tornadoweb/tornado
tornado/tcpserver.py
TCPServer.stop
def stop(self) -> None: """Stops listening for new connections. Requests currently in progress may still continue after the server is stopped. """ if self._stopped: return self._stopped = True for fd, sock in self._sockets.items(): assert ...
python
def stop(self) -> None: """Stops listening for new connections. Requests currently in progress may still continue after the server is stopped. """ if self._stopped: return self._stopped = True for fd, sock in self._sockets.items(): assert ...
[ "def", "stop", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_stopped", ":", "return", "self", ".", "_stopped", "=", "True", "for", "fd", ",", "sock", "in", "self", ".", "_sockets", ".", "items", "(", ")", ":", "assert", "sock", ".", "...
Stops listening for new connections. Requests currently in progress may still continue after the server is stopped.
[ "Stops", "listening", "for", "new", "connections", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpserver.py#L248-L261
26,866
tornadoweb/tornado
tornado/queues.py
Queue.put
def put( self, item: _T, timeout: Union[float, datetime.timedelta] = None ) -> "Future[None]": """Put an item into the queue, perhaps waiting until there is room. Returns a Future, which raises `tornado.util.TimeoutError` after a timeout. ``timeout`` may be a number denotin...
python
def put( self, item: _T, timeout: Union[float, datetime.timedelta] = None ) -> "Future[None]": """Put an item into the queue, perhaps waiting until there is room. Returns a Future, which raises `tornado.util.TimeoutError` after a timeout. ``timeout`` may be a number denotin...
[ "def", "put", "(", "self", ",", "item", ":", "_T", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "\"Future[None]\"", ":", "future", "=", "Future", "(", ")", "# type: Future[None]", "try", ":...
Put an item into the queue, perhaps waiting until there is room. Returns a Future, which raises `tornado.util.TimeoutError` after a timeout. ``timeout`` may be a number denoting a time (on the same scale as `tornado.ioloop.IOLoop.time`, normally `time.time`), or a `datetime.tim...
[ "Put", "an", "item", "into", "the", "queue", "perhaps", "waiting", "until", "there", "is", "room", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/queues.py#L186-L207
26,867
tornadoweb/tornado
tornado/queues.py
Queue.get_nowait
def get_nowait(self) -> _T: """Remove and return an item from the queue without blocking. Return an item if one is immediately available, else raise `QueueEmpty`. """ self._consume_expired() if self._putters: assert self.full(), "queue not full, why are putte...
python
def get_nowait(self) -> _T: """Remove and return an item from the queue without blocking. Return an item if one is immediately available, else raise `QueueEmpty`. """ self._consume_expired() if self._putters: assert self.full(), "queue not full, why are putte...
[ "def", "get_nowait", "(", "self", ")", "->", "_T", ":", "self", ".", "_consume_expired", "(", ")", "if", "self", ".", "_putters", ":", "assert", "self", ".", "full", "(", ")", ",", "\"queue not full, why are putters waiting?\"", "item", ",", "putter", "=", ...
Remove and return an item from the queue without blocking. Return an item if one is immediately available, else raise `QueueEmpty`.
[ "Remove", "and", "return", "an", "item", "from", "the", "queue", "without", "blocking", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/queues.py#L254-L270
26,868
tornadoweb/tornado
tornado/queues.py
Queue.join
def join(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[None]: """Block until all items in the queue are processed. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout. """ return self._finished.wait(timeout)
python
def join(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[None]: """Block until all items in the queue are processed. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout. """ return self._finished.wait(timeout)
[ "def", "join", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "None", "]", ":", "return", "self", ".", "_finished", ".", "wait", "(", "timeout", ")" ]
Block until all items in the queue are processed. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout.
[ "Block", "until", "all", "items", "in", "the", "queue", "are", "processed", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/queues.py#L290-L296
26,869
tornadoweb/tornado
tornado/process.py
cpu_count
def cpu_count() -> int: """Returns the number of processors on this machine.""" if multiprocessing is None: return 1 try: return multiprocessing.cpu_count() except NotImplementedError: pass try: return os.sysconf("SC_NPROCESSORS_CONF") except (AttributeError, Valu...
python
def cpu_count() -> int: """Returns the number of processors on this machine.""" if multiprocessing is None: return 1 try: return multiprocessing.cpu_count() except NotImplementedError: pass try: return os.sysconf("SC_NPROCESSORS_CONF") except (AttributeError, Valu...
[ "def", "cpu_count", "(", ")", "->", "int", ":", "if", "multiprocessing", "is", "None", ":", "return", "1", "try", ":", "return", "multiprocessing", ".", "cpu_count", "(", ")", "except", "NotImplementedError", ":", "pass", "try", ":", "return", "os", ".", ...
Returns the number of processors on this machine.
[ "Returns", "the", "number", "of", "processors", "on", "this", "machine", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L51-L64
26,870
tornadoweb/tornado
tornado/process.py
fork_processes
def fork_processes(num_processes: Optional[int], max_restarts: int = None) -> int: """Starts multiple worker processes. If ``num_processes`` is None or <= 0, we detect the number of cores available on this machine and fork that number of child processes. If ``num_processes`` is given and > 0, we fork t...
python
def fork_processes(num_processes: Optional[int], max_restarts: int = None) -> int: """Starts multiple worker processes. If ``num_processes`` is None or <= 0, we detect the number of cores available on this machine and fork that number of child processes. If ``num_processes`` is given and > 0, we fork t...
[ "def", "fork_processes", "(", "num_processes", ":", "Optional", "[", "int", "]", ",", "max_restarts", ":", "int", "=", "None", ")", "->", "int", ":", "if", "max_restarts", "is", "None", ":", "max_restarts", "=", "100", "global", "_task_id", "assert", "_tas...
Starts multiple worker processes. If ``num_processes`` is None or <= 0, we detect the number of cores available on this machine and fork that number of child processes. If ``num_processes`` is given and > 0, we fork that specific number of sub-processes. Since we use processes and not threads, the...
[ "Starts", "multiple", "worker", "processes", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L92-L185
26,871
tornadoweb/tornado
tornado/process.py
Subprocess.set_exit_callback
def set_exit_callback(self, callback: Callable[[int], None]) -> None: """Runs ``callback`` when this process exits. The callback takes one argument, the return code of the process. This method uses a ``SIGCHLD`` handler, which is a global setting and may conflict if you have other libr...
python
def set_exit_callback(self, callback: Callable[[int], None]) -> None: """Runs ``callback`` when this process exits. The callback takes one argument, the return code of the process. This method uses a ``SIGCHLD`` handler, which is a global setting and may conflict if you have other libr...
[ "def", "set_exit_callback", "(", "self", ",", "callback", ":", "Callable", "[", "[", "int", "]", ",", "None", "]", ")", "->", "None", ":", "self", ".", "_exit_callback", "=", "callback", "Subprocess", ".", "initialize", "(", ")", "Subprocess", ".", "_wai...
Runs ``callback`` when this process exits. The callback takes one argument, the return code of the process. This method uses a ``SIGCHLD`` handler, which is a global setting and may conflict if you have other libraries trying to handle the same signal. If you are using more than one `...
[ "Runs", "callback", "when", "this", "process", "exits", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L264-L284
26,872
tornadoweb/tornado
tornado/process.py
Subprocess.wait_for_exit
def wait_for_exit(self, raise_error: bool = True) -> "Future[int]": """Returns a `.Future` which resolves when the process exits. Usage:: ret = yield proc.wait_for_exit() This is a coroutine-friendly alternative to `set_exit_callback` (and a replacement for the blocking `s...
python
def wait_for_exit(self, raise_error: bool = True) -> "Future[int]": """Returns a `.Future` which resolves when the process exits. Usage:: ret = yield proc.wait_for_exit() This is a coroutine-friendly alternative to `set_exit_callback` (and a replacement for the blocking `s...
[ "def", "wait_for_exit", "(", "self", ",", "raise_error", ":", "bool", "=", "True", ")", "->", "\"Future[int]\"", ":", "future", "=", "Future", "(", ")", "# type: Future[int]", "def", "callback", "(", "ret", ":", "int", ")", "->", "None", ":", "if", "ret"...
Returns a `.Future` which resolves when the process exits. Usage:: ret = yield proc.wait_for_exit() This is a coroutine-friendly alternative to `set_exit_callback` (and a replacement for the blocking `subprocess.Popen.wait`). By default, raises `subprocess.CalledProcessEr...
[ "Returns", "a", ".", "Future", "which", "resolves", "when", "the", "process", "exits", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L286-L316
26,873
tornadoweb/tornado
tornado/process.py
Subprocess.initialize
def initialize(cls) -> None: """Initializes the ``SIGCHLD`` handler. The signal handler is run on an `.IOLoop` to avoid locking issues. Note that the `.IOLoop` used for signal handling need not be the same one used by individual Subprocess objects (as long as the ``IOLoops`` are...
python
def initialize(cls) -> None: """Initializes the ``SIGCHLD`` handler. The signal handler is run on an `.IOLoop` to avoid locking issues. Note that the `.IOLoop` used for signal handling need not be the same one used by individual Subprocess objects (as long as the ``IOLoops`` are...
[ "def", "initialize", "(", "cls", ")", "->", "None", ":", "if", "cls", ".", "_initialized", ":", "return", "io_loop", "=", "ioloop", ".", "IOLoop", ".", "current", "(", ")", "cls", ".", "_old_sigchld", "=", "signal", ".", "signal", "(", "signal", ".", ...
Initializes the ``SIGCHLD`` handler. The signal handler is run on an `.IOLoop` to avoid locking issues. Note that the `.IOLoop` used for signal handling need not be the same one used by individual Subprocess objects (as long as the ``IOLoops`` are each running in separate threads). ...
[ "Initializes", "the", "SIGCHLD", "handler", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L319-L340
26,874
tornadoweb/tornado
tornado/process.py
Subprocess.uninitialize
def uninitialize(cls) -> None: """Removes the ``SIGCHLD`` handler.""" if not cls._initialized: return signal.signal(signal.SIGCHLD, cls._old_sigchld) cls._initialized = False
python
def uninitialize(cls) -> None: """Removes the ``SIGCHLD`` handler.""" if not cls._initialized: return signal.signal(signal.SIGCHLD, cls._old_sigchld) cls._initialized = False
[ "def", "uninitialize", "(", "cls", ")", "->", "None", ":", "if", "not", "cls", ".", "_initialized", ":", "return", "signal", ".", "signal", "(", "signal", ".", "SIGCHLD", ",", "cls", ".", "_old_sigchld", ")", "cls", ".", "_initialized", "=", "False" ]
Removes the ``SIGCHLD`` handler.
[ "Removes", "the", "SIGCHLD", "handler", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L343-L348
26,875
tornadoweb/tornado
tornado/curl_httpclient.py
CurlAsyncHTTPClient._handle_socket
def _handle_socket(self, event: int, fd: int, multi: Any, data: bytes) -> None: """Called by libcurl when it wants to change the file descriptors it cares about. """ event_map = { pycurl.POLL_NONE: ioloop.IOLoop.NONE, pycurl.POLL_IN: ioloop.IOLoop.READ, ...
python
def _handle_socket(self, event: int, fd: int, multi: Any, data: bytes) -> None: """Called by libcurl when it wants to change the file descriptors it cares about. """ event_map = { pycurl.POLL_NONE: ioloop.IOLoop.NONE, pycurl.POLL_IN: ioloop.IOLoop.READ, ...
[ "def", "_handle_socket", "(", "self", ",", "event", ":", "int", ",", "fd", ":", "int", ",", "multi", ":", "Any", ",", "data", ":", "bytes", ")", "->", "None", ":", "event_map", "=", "{", "pycurl", ".", "POLL_NONE", ":", "ioloop", ".", "IOLoop", "."...
Called by libcurl when it wants to change the file descriptors it cares about.
[ "Called", "by", "libcurl", "when", "it", "wants", "to", "change", "the", "file", "descriptors", "it", "cares", "about", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L104-L131
26,876
tornadoweb/tornado
tornado/curl_httpclient.py
CurlAsyncHTTPClient._set_timeout
def _set_timeout(self, msecs: int) -> None: """Called by libcurl to schedule a timeout.""" if self._timeout is not None: self.io_loop.remove_timeout(self._timeout) self._timeout = self.io_loop.add_timeout( self.io_loop.time() + msecs / 1000.0, self._handle_timeout ...
python
def _set_timeout(self, msecs: int) -> None: """Called by libcurl to schedule a timeout.""" if self._timeout is not None: self.io_loop.remove_timeout(self._timeout) self._timeout = self.io_loop.add_timeout( self.io_loop.time() + msecs / 1000.0, self._handle_timeout ...
[ "def", "_set_timeout", "(", "self", ",", "msecs", ":", "int", ")", "->", "None", ":", "if", "self", ".", "_timeout", "is", "not", "None", ":", "self", ".", "io_loop", ".", "remove_timeout", "(", "self", ".", "_timeout", ")", "self", ".", "_timeout", ...
Called by libcurl to schedule a timeout.
[ "Called", "by", "libcurl", "to", "schedule", "a", "timeout", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L133-L139
26,877
tornadoweb/tornado
tornado/curl_httpclient.py
CurlAsyncHTTPClient._handle_events
def _handle_events(self, fd: int, events: int) -> None: """Called by IOLoop when there is activity on one of our file descriptors. """ action = 0 if events & ioloop.IOLoop.READ: action |= pycurl.CSELECT_IN if events & ioloop.IOLoop.WRITE: action |=...
python
def _handle_events(self, fd: int, events: int) -> None: """Called by IOLoop when there is activity on one of our file descriptors. """ action = 0 if events & ioloop.IOLoop.READ: action |= pycurl.CSELECT_IN if events & ioloop.IOLoop.WRITE: action |=...
[ "def", "_handle_events", "(", "self", ",", "fd", ":", "int", ",", "events", ":", "int", ")", "->", "None", ":", "action", "=", "0", "if", "events", "&", "ioloop", ".", "IOLoop", ".", "READ", ":", "action", "|=", "pycurl", ".", "CSELECT_IN", "if", "...
Called by IOLoop when there is activity on one of our file descriptors.
[ "Called", "by", "IOLoop", "when", "there", "is", "activity", "on", "one", "of", "our", "file", "descriptors", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L141-L157
26,878
tornadoweb/tornado
tornado/curl_httpclient.py
CurlAsyncHTTPClient._handle_timeout
def _handle_timeout(self) -> None: """Called by IOLoop when the requested timeout has passed.""" self._timeout = None while True: try: ret, num_handles = self._multi.socket_action(pycurl.SOCKET_TIMEOUT, 0) except pycurl.error as e: ret = e....
python
def _handle_timeout(self) -> None: """Called by IOLoop when the requested timeout has passed.""" self._timeout = None while True: try: ret, num_handles = self._multi.socket_action(pycurl.SOCKET_TIMEOUT, 0) except pycurl.error as e: ret = e....
[ "def", "_handle_timeout", "(", "self", ")", "->", "None", ":", "self", ".", "_timeout", "=", "None", "while", "True", ":", "try", ":", "ret", ",", "num_handles", "=", "self", ".", "_multi", ".", "socket_action", "(", "pycurl", ".", "SOCKET_TIMEOUT", ",",...
Called by IOLoop when the requested timeout has passed.
[ "Called", "by", "IOLoop", "when", "the", "requested", "timeout", "has", "passed", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L159-L186
26,879
tornadoweb/tornado
tornado/curl_httpclient.py
CurlAsyncHTTPClient._handle_force_timeout
def _handle_force_timeout(self) -> None: """Called by IOLoop periodically to ask libcurl to process any events it may have forgotten about. """ while True: try: ret, num_handles = self._multi.socket_all() except pycurl.error as e: r...
python
def _handle_force_timeout(self) -> None: """Called by IOLoop periodically to ask libcurl to process any events it may have forgotten about. """ while True: try: ret, num_handles = self._multi.socket_all() except pycurl.error as e: r...
[ "def", "_handle_force_timeout", "(", "self", ")", "->", "None", ":", "while", "True", ":", "try", ":", "ret", ",", "num_handles", "=", "self", ".", "_multi", ".", "socket_all", "(", ")", "except", "pycurl", ".", "error", "as", "e", ":", "ret", "=", "...
Called by IOLoop periodically to ask libcurl to process any events it may have forgotten about.
[ "Called", "by", "IOLoop", "periodically", "to", "ask", "libcurl", "to", "process", "any", "events", "it", "may", "have", "forgotten", "about", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L188-L199
26,880
tornadoweb/tornado
tornado/curl_httpclient.py
CurlAsyncHTTPClient._finish_pending_requests
def _finish_pending_requests(self) -> None: """Process any requests that were completed by the last call to multi.socket_action. """ while True: num_q, ok_list, err_list = self._multi.info_read() for curl in ok_list: self._finish(curl) ...
python
def _finish_pending_requests(self) -> None: """Process any requests that were completed by the last call to multi.socket_action. """ while True: num_q, ok_list, err_list = self._multi.info_read() for curl in ok_list: self._finish(curl) ...
[ "def", "_finish_pending_requests", "(", "self", ")", "->", "None", ":", "while", "True", ":", "num_q", ",", "ok_list", ",", "err_list", "=", "self", ".", "_multi", ".", "info_read", "(", ")", "for", "curl", "in", "ok_list", ":", "self", ".", "_finish", ...
Process any requests that were completed by the last call to multi.socket_action.
[ "Process", "any", "requests", "that", "were", "completed", "by", "the", "last", "call", "to", "multi", ".", "socket_action", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L201-L213
26,881
tornadoweb/tornado
demos/s3server/s3server.py
start
def start(port, root_directory, bucket_depth): """Starts the mock S3 server on the given port at the given path.""" application = S3Application(root_directory, bucket_depth) http_server = httpserver.HTTPServer(application) http_server.listen(port) ioloop.IOLoop.current().start()
python
def start(port, root_directory, bucket_depth): """Starts the mock S3 server on the given port at the given path.""" application = S3Application(root_directory, bucket_depth) http_server = httpserver.HTTPServer(application) http_server.listen(port) ioloop.IOLoop.current().start()
[ "def", "start", "(", "port", ",", "root_directory", ",", "bucket_depth", ")", ":", "application", "=", "S3Application", "(", "root_directory", ",", "bucket_depth", ")", "http_server", "=", "httpserver", ".", "HTTPServer", "(", "application", ")", "http_server", ...
Starts the mock S3 server on the given port at the given path.
[ "Starts", "the", "mock", "S3", "server", "on", "the", "given", "port", "at", "the", "given", "path", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/demos/s3server/s3server.py#L57-L62
26,882
tornadoweb/tornado
tornado/httpclient.py
HTTPClient.close
def close(self) -> None: """Closes the HTTPClient, freeing any resources used.""" if not self._closed: self._async_client.close() self._io_loop.close() self._closed = True
python
def close(self) -> None: """Closes the HTTPClient, freeing any resources used.""" if not self._closed: self._async_client.close() self._io_loop.close() self._closed = True
[ "def", "close", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "_closed", ":", "self", ".", "_async_client", ".", "close", "(", ")", "self", ".", "_io_loop", ".", "close", "(", ")", "self", ".", "_closed", "=", "True" ]
Closes the HTTPClient, freeing any resources used.
[ "Closes", "the", "HTTPClient", "freeing", "any", "resources", "used", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpclient.py#L113-L118
26,883
tornadoweb/tornado
tornado/httpclient.py
HTTPClient.fetch
def fetch( self, request: Union["HTTPRequest", str], **kwargs: Any ) -> "HTTPResponse": """Executes a request, returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. If it is a string, we construct an `HTTPRequest` using any additional ...
python
def fetch( self, request: Union["HTTPRequest", str], **kwargs: Any ) -> "HTTPResponse": """Executes a request, returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. If it is a string, we construct an `HTTPRequest` using any additional ...
[ "def", "fetch", "(", "self", ",", "request", ":", "Union", "[", "\"HTTPRequest\"", ",", "str", "]", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "\"HTTPResponse\"", ":", "response", "=", "self", ".", "_io_loop", ".", "run_sync", "(", "functools", "....
Executes a request, returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. If it is a string, we construct an `HTTPRequest` using any additional kwargs: ``HTTPRequest(request, **kwargs)`` If an error occurs during the fetch, we raise an `HTTPErr...
[ "Executes", "a", "request", "returning", "an", "HTTPResponse", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpclient.py#L120-L135
26,884
tornadoweb/tornado
tornado/httpclient.py
AsyncHTTPClient.close
def close(self) -> None: """Destroys this HTTP client, freeing any file descriptors used. This method is **not needed in normal use** due to the way that `AsyncHTTPClient` objects are transparently reused. ``close()`` is generally only necessary when either the `.IOLoop` is also...
python
def close(self) -> None: """Destroys this HTTP client, freeing any file descriptors used. This method is **not needed in normal use** due to the way that `AsyncHTTPClient` objects are transparently reused. ``close()`` is generally only necessary when either the `.IOLoop` is also...
[ "def", "close", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_closed", ":", "return", "self", ".", "_closed", "=", "True", "if", "self", ".", "_instance_cache", "is", "not", "None", ":", "cached_val", "=", "self", ".", "_instance_cache", "....
Destroys this HTTP client, freeing any file descriptors used. This method is **not needed in normal use** due to the way that `AsyncHTTPClient` objects are transparently reused. ``close()`` is generally only necessary when either the `.IOLoop` is also being closed, or the ``force_instan...
[ "Destroys", "this", "HTTP", "client", "freeing", "any", "file", "descriptors", "used", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpclient.py#L221-L245
26,885
tornadoweb/tornado
tornado/httpclient.py
AsyncHTTPClient.fetch
def fetch( self, request: Union[str, "HTTPRequest"], raise_error: bool = True, **kwargs: Any ) -> Awaitable["HTTPResponse"]: """Executes a request, asynchronously returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. ...
python
def fetch( self, request: Union[str, "HTTPRequest"], raise_error: bool = True, **kwargs: Any ) -> Awaitable["HTTPResponse"]: """Executes a request, asynchronously returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. ...
[ "def", "fetch", "(", "self", ",", "request", ":", "Union", "[", "str", ",", "\"HTTPRequest\"", "]", ",", "raise_error", ":", "bool", "=", "True", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "Awaitable", "[", "\"HTTPResponse\"", "]", ":", "if", "s...
Executes a request, asynchronously returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. If it is a string, we construct an `HTTPRequest` using any additional kwargs: ``HTTPRequest(request, **kwargs)`` This method returns a `.Future` whose resu...
[ "Executes", "a", "request", "asynchronously", "returning", "an", "HTTPResponse", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpclient.py#L247-L305
26,886
tornadoweb/tornado
tornado/httpclient.py
AsyncHTTPClient.configure
def configure( cls, impl: "Union[None, str, Type[Configurable]]", **kwargs: Any ) -> None: """Configures the `AsyncHTTPClient` subclass to use. ``AsyncHTTPClient()`` actually creates an instance of a subclass. This method may be called with either a class object or the fully...
python
def configure( cls, impl: "Union[None, str, Type[Configurable]]", **kwargs: Any ) -> None: """Configures the `AsyncHTTPClient` subclass to use. ``AsyncHTTPClient()`` actually creates an instance of a subclass. This method may be called with either a class object or the fully...
[ "def", "configure", "(", "cls", ",", "impl", ":", "\"Union[None, str, Type[Configurable]]\"", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "super", "(", "AsyncHTTPClient", ",", "cls", ")", ".", "configure", "(", "impl", ",", "*", "*", "kw...
Configures the `AsyncHTTPClient` subclass to use. ``AsyncHTTPClient()`` actually creates an instance of a subclass. This method may be called with either a class object or the fully-qualified name of such a class (or ``None`` to use the default, ``SimpleAsyncHTTPClient``) If ad...
[ "Configures", "the", "AsyncHTTPClient", "subclass", "to", "use", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpclient.py#L313-L334
26,887
aio-libs/aiohttp
aiohttp/connector.py
BaseConnector._cleanup
def _cleanup(self) -> None: """Cleanup unused transports.""" if self._cleanup_handle: self._cleanup_handle.cancel() now = self._loop.time() timeout = self._keepalive_timeout if self._conns: connections = {} deadline = now - timeout ...
python
def _cleanup(self) -> None: """Cleanup unused transports.""" if self._cleanup_handle: self._cleanup_handle.cancel() now = self._loop.time() timeout = self._keepalive_timeout if self._conns: connections = {} deadline = now - timeout ...
[ "def", "_cleanup", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_cleanup_handle", ":", "self", ".", "_cleanup_handle", ".", "cancel", "(", ")", "now", "=", "self", ".", "_loop", ".", "time", "(", ")", "timeout", "=", "self", ".", "_keepal...
Cleanup unused transports.
[ "Cleanup", "unused", "transports", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L327-L359
26,888
aio-libs/aiohttp
aiohttp/connector.py
BaseConnector._cleanup_closed
def _cleanup_closed(self) -> None: """Double confirmation for transport close. Some broken ssl servers may leave socket open without proper close. """ if self._cleanup_closed_handle: self._cleanup_closed_handle.cancel() for transport in self._cleanup_closed_transport...
python
def _cleanup_closed(self) -> None: """Double confirmation for transport close. Some broken ssl servers may leave socket open without proper close. """ if self._cleanup_closed_handle: self._cleanup_closed_handle.cancel() for transport in self._cleanup_closed_transport...
[ "def", "_cleanup_closed", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_cleanup_closed_handle", ":", "self", ".", "_cleanup_closed_handle", ".", "cancel", "(", ")", "for", "transport", "in", "self", ".", "_cleanup_closed_transports", ":", "if", "tr...
Double confirmation for transport close. Some broken ssl servers may leave socket open without proper close.
[ "Double", "confirmation", "for", "transport", "close", ".", "Some", "broken", "ssl", "servers", "may", "leave", "socket", "open", "without", "proper", "close", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L371-L387
26,889
aio-libs/aiohttp
aiohttp/connector.py
BaseConnector._available_connections
def _available_connections(self, key: 'ConnectionKey') -> int: """ Return number of available connections taking into account the limit, limit_per_host and the connection key. If it returns less than 1 means that there is no connections availables. """ if self._...
python
def _available_connections(self, key: 'ConnectionKey') -> int: """ Return number of available connections taking into account the limit, limit_per_host and the connection key. If it returns less than 1 means that there is no connections availables. """ if self._...
[ "def", "_available_connections", "(", "self", ",", "key", ":", "'ConnectionKey'", ")", "->", "int", ":", "if", "self", ".", "_limit", ":", "# total calc available connections", "available", "=", "self", ".", "_limit", "-", "len", "(", "self", ".", "_acquired",...
Return number of available connections taking into account the limit, limit_per_host and the connection key. If it returns less than 1 means that there is no connections availables.
[ "Return", "number", "of", "available", "connections", "taking", "into", "account", "the", "limit", "limit_per_host", "and", "the", "connection", "key", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L439-L467
26,890
aio-libs/aiohttp
aiohttp/connector.py
BaseConnector.connect
async def connect(self, req: 'ClientRequest', traces: List['Trace'], timeout: 'ClientTimeout') -> Connection: """Get from pool or create new connection.""" key = req.connection_key available = self._available_connections(key) # Wait if there a...
python
async def connect(self, req: 'ClientRequest', traces: List['Trace'], timeout: 'ClientTimeout') -> Connection: """Get from pool or create new connection.""" key = req.connection_key available = self._available_connections(key) # Wait if there a...
[ "async", "def", "connect", "(", "self", ",", "req", ":", "'ClientRequest'", ",", "traces", ":", "List", "[", "'Trace'", "]", ",", "timeout", ":", "'ClientTimeout'", ")", "->", "Connection", ":", "key", "=", "req", ".", "connection_key", "available", "=", ...
Get from pool or create new connection.
[ "Get", "from", "pool", "or", "create", "new", "connection", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L469-L547
26,891
aio-libs/aiohttp
aiohttp/connector.py
BaseConnector._release_waiter
def _release_waiter(self) -> None: """ Iterates over all waiters till found one that is not finsihed and belongs to a host that has available connections. """ if not self._waiters: return # Having the dict keys ordered this avoids to iterate # at the ...
python
def _release_waiter(self) -> None: """ Iterates over all waiters till found one that is not finsihed and belongs to a host that has available connections. """ if not self._waiters: return # Having the dict keys ordered this avoids to iterate # at the ...
[ "def", "_release_waiter", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "_waiters", ":", "return", "# Having the dict keys ordered this avoids to iterate", "# at the same order at each call.", "queues", "=", "list", "(", "self", ".", "_waiters", ".", ...
Iterates over all waiters till found one that is not finsihed and belongs to a host that has available connections.
[ "Iterates", "over", "all", "waiters", "till", "found", "one", "that", "is", "not", "finsihed", "and", "belongs", "to", "a", "host", "that", "has", "available", "connections", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L575-L597
26,892
aio-libs/aiohttp
aiohttp/connector.py
TCPConnector.close
def close(self) -> Awaitable[None]: """Close all ongoing DNS calls.""" for ev in self._throttle_dns_events.values(): ev.cancel() return super().close()
python
def close(self) -> Awaitable[None]: """Close all ongoing DNS calls.""" for ev in self._throttle_dns_events.values(): ev.cancel() return super().close()
[ "def", "close", "(", "self", ")", "->", "Awaitable", "[", "None", "]", ":", "for", "ev", "in", "self", ".", "_throttle_dns_events", ".", "values", "(", ")", ":", "ev", ".", "cancel", "(", ")", "return", "super", "(", ")", ".", "close", "(", ")" ]
Close all ongoing DNS calls.
[ "Close", "all", "ongoing", "DNS", "calls", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L744-L749
26,893
aio-libs/aiohttp
aiohttp/connector.py
TCPConnector._create_connection
async def _create_connection(self, req: 'ClientRequest', traces: List['Trace'], timeout: 'ClientTimeout') -> ResponseHandler: """Create connection. Has same keyword arguments as BaseEventLoop.create_connection. """ if req...
python
async def _create_connection(self, req: 'ClientRequest', traces: List['Trace'], timeout: 'ClientTimeout') -> ResponseHandler: """Create connection. Has same keyword arguments as BaseEventLoop.create_connection. """ if req...
[ "async", "def", "_create_connection", "(", "self", ",", "req", ":", "'ClientRequest'", ",", "traces", ":", "List", "[", "'Trace'", "]", ",", "timeout", ":", "'ClientTimeout'", ")", "->", "ResponseHandler", ":", "if", "req", ".", "proxy", ":", "_", ",", "...
Create connection. Has same keyword arguments as BaseEventLoop.create_connection.
[ "Create", "connection", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L842-L856
26,894
aio-libs/aiohttp
aiohttp/connector.py
TCPConnector._get_ssl_context
def _get_ssl_context(self, req: 'ClientRequest') -> Optional[SSLContext]: """Logic to get the correct SSL context 0. if req.ssl is false, return None 1. if ssl_context is specified in req, use it 2. if _ssl_context is specified in self, use it 3. otherwise: 1. if ve...
python
def _get_ssl_context(self, req: 'ClientRequest') -> Optional[SSLContext]: """Logic to get the correct SSL context 0. if req.ssl is false, return None 1. if ssl_context is specified in req, use it 2. if _ssl_context is specified in self, use it 3. otherwise: 1. if ve...
[ "def", "_get_ssl_context", "(", "self", ",", "req", ":", "'ClientRequest'", ")", "->", "Optional", "[", "SSLContext", "]", ":", "if", "req", ".", "is_ssl", "(", ")", ":", "if", "ssl", "is", "None", ":", "# pragma: no cover", "raise", "RuntimeError", "(", ...
Logic to get the correct SSL context 0. if req.ssl is false, return None 1. if ssl_context is specified in req, use it 2. if _ssl_context is specified in self, use it 3. otherwise: 1. if verify_ssl is not specified in req, use self.ssl_context (will generate ...
[ "Logic", "to", "get", "the", "correct", "SSL", "context" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L871-L902
26,895
aio-libs/aiohttp
aiohttp/http_websocket.py
WSMessage.json
def json(self, *, # type: ignore loads: Callable[[Any], Any]=json.loads) -> None: """Return parsed JSON data. .. versionadded:: 0.22 """ return loads(self.data)
python
def json(self, *, # type: ignore loads: Callable[[Any], Any]=json.loads) -> None: """Return parsed JSON data. .. versionadded:: 0.22 """ return loads(self.data)
[ "def", "json", "(", "self", ",", "*", ",", "# type: ignore", "loads", ":", "Callable", "[", "[", "Any", "]", ",", "Any", "]", "=", "json", ".", "loads", ")", "->", "None", ":", "return", "loads", "(", "self", ".", "data", ")" ]
Return parsed JSON data. .. versionadded:: 0.22
[ "Return", "parsed", "JSON", "data", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/http_websocket.py#L85-L91
26,896
aio-libs/aiohttp
aiohttp/http_websocket.py
WebSocketWriter.pong
async def pong(self, message: bytes=b'') -> None: """Send pong message.""" if isinstance(message, str): message = message.encode('utf-8') await self._send_frame(message, WSMsgType.PONG)
python
async def pong(self, message: bytes=b'') -> None: """Send pong message.""" if isinstance(message, str): message = message.encode('utf-8') await self._send_frame(message, WSMsgType.PONG)
[ "async", "def", "pong", "(", "self", ",", "message", ":", "bytes", "=", "b''", ")", "->", "None", ":", "if", "isinstance", "(", "message", ",", "str", ")", ":", "message", "=", "message", ".", "encode", "(", "'utf-8'", ")", "await", "self", ".", "_...
Send pong message.
[ "Send", "pong", "message", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/http_websocket.py#L622-L626
26,897
aio-libs/aiohttp
aiohttp/http_websocket.py
WebSocketWriter.ping
async def ping(self, message: bytes=b'') -> None: """Send ping message.""" if isinstance(message, str): message = message.encode('utf-8') await self._send_frame(message, WSMsgType.PING)
python
async def ping(self, message: bytes=b'') -> None: """Send ping message.""" if isinstance(message, str): message = message.encode('utf-8') await self._send_frame(message, WSMsgType.PING)
[ "async", "def", "ping", "(", "self", ",", "message", ":", "bytes", "=", "b''", ")", "->", "None", ":", "if", "isinstance", "(", "message", ",", "str", ")", ":", "message", "=", "message", ".", "encode", "(", "'utf-8'", ")", "await", "self", ".", "_...
Send ping message.
[ "Send", "ping", "message", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/http_websocket.py#L628-L632
26,898
aio-libs/aiohttp
aiohttp/cookiejar.py
CookieJar.update_cookies
def update_cookies(self, cookies: LooseCookies, response_url: URL=URL()) -> None: """Update cookies.""" hostname = response_url.raw_host if not self._unsafe and is_ip_address(hostname): # Don't accept cookies from IPs return ...
python
def update_cookies(self, cookies: LooseCookies, response_url: URL=URL()) -> None: """Update cookies.""" hostname = response_url.raw_host if not self._unsafe and is_ip_address(hostname): # Don't accept cookies from IPs return ...
[ "def", "update_cookies", "(", "self", ",", "cookies", ":", "LooseCookies", ",", "response_url", ":", "URL", "=", "URL", "(", ")", ")", "->", "None", ":", "hostname", "=", "response_url", ".", "raw_host", "if", "not", "self", ".", "_unsafe", "and", "is_ip...
Update cookies.
[ "Update", "cookies", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/cookiejar.py#L113-L186
26,899
aio-libs/aiohttp
aiohttp/cookiejar.py
CookieJar.filter_cookies
def filter_cookies(self, request_url: URL=URL()) -> 'BaseCookie[str]': """Returns this jar's cookies filtered by their attributes.""" self._do_expiration() request_url = URL(request_url) filtered = SimpleCookie() hostname = request_url.raw_host or "" is_not_secure = reque...
python
def filter_cookies(self, request_url: URL=URL()) -> 'BaseCookie[str]': """Returns this jar's cookies filtered by their attributes.""" self._do_expiration() request_url = URL(request_url) filtered = SimpleCookie() hostname = request_url.raw_host or "" is_not_secure = reque...
[ "def", "filter_cookies", "(", "self", ",", "request_url", ":", "URL", "=", "URL", "(", ")", ")", "->", "'BaseCookie[str]'", ":", "self", ".", "_do_expiration", "(", ")", "request_url", "=", "URL", "(", "request_url", ")", "filtered", "=", "SimpleCookie", "...
Returns this jar's cookies filtered by their attributes.
[ "Returns", "this", "jar", "s", "cookies", "filtered", "by", "their", "attributes", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/cookiejar.py#L188-L226