partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
StaticFileHandler.get_content_type
Returns the ``Content-Type`` header to be used for this request. .. versionadded:: 3.1
tornado/web.py
def get_content_type(self) -> str: """Returns the ``Content-Type`` header to be used for this request. .. versionadded:: 3.1 """ assert self.absolute_path is not None mime_type, encoding = mimetypes.guess_type(self.absolute_path) # per RFC 6713, use the appropriate type ...
def get_content_type(self) -> str: """Returns the ``Content-Type`` header to be used for this request. .. versionadded:: 3.1 """ assert self.absolute_path is not None mime_type, encoding = mimetypes.guess_type(self.absolute_path) # per RFC 6713, use the appropriate type ...
[ "Returns", "the", "Content", "-", "Type", "header", "to", "be", "used", "for", "this", "request", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2881-L2900
[ "def", "get_content_type", "(", "self", ")", "->", "str", ":", "assert", "self", ".", "absolute_path", "is", "not", "None", "mime_type", ",", "encoding", "=", "mimetypes", ".", "guess_type", "(", "self", ".", "absolute_path", ")", "# per RFC 6713, use the approp...
b8b481770bcdb333a69afde5cce7eaa449128326
train
StaticFileHandler.get_cache_time
Override to customize cache control behavior. Return a positive number of seconds to make the result cacheable for that amount of time or 0 to mark resource as cacheable for an unspecified amount of time (subject to browser heuristics). By default returns cache expiry of 10 yea...
tornado/web.py
def get_cache_time( self, path: str, modified: Optional[datetime.datetime], mime_type: str ) -> int: """Override to customize cache control behavior. Return a positive number of seconds to make the result cacheable for that amount of time or 0 to mark resource as cacheable f...
def get_cache_time( self, path: str, modified: Optional[datetime.datetime], mime_type: str ) -> int: """Override to customize cache control behavior. Return a positive number of seconds to make the result cacheable for that amount of time or 0 to mark resource as cacheable f...
[ "Override", "to", "customize", "cache", "control", "behavior", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2906-L2919
[ "def", "get_cache_time", "(", "self", ",", "path", ":", "str", ",", "modified", ":", "Optional", "[", "datetime", ".", "datetime", "]", ",", "mime_type", ":", "str", ")", "->", "int", ":", "return", "self", ".", "CACHE_MAX_AGE", "if", "\"v\"", "in", "s...
b8b481770bcdb333a69afde5cce7eaa449128326
train
StaticFileHandler.make_static_url
Constructs a versioned url for the given path. This method may be overridden in subclasses (but note that it is a class method rather than an instance method). Subclasses are only required to implement the signature ``make_static_url(cls, settings, path)``; other keyword argume...
tornado/web.py
def make_static_url( cls, settings: Dict[str, Any], path: str, include_version: bool = True ) -> str: """Constructs a versioned url for the given path. This method may be overridden in subclasses (but note that it is a class method rather than an instance method). Subclasses ...
def make_static_url( cls, settings: Dict[str, Any], path: str, include_version: bool = True ) -> str: """Constructs a versioned url for the given path. This method may be overridden in subclasses (but note that it is a class method rather than an instance method). Subclasses ...
[ "Constructs", "a", "versioned", "url", "for", "the", "given", "path", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2922-L2951
[ "def", "make_static_url", "(", "cls", ",", "settings", ":", "Dict", "[", "str", ",", "Any", "]", ",", "path", ":", "str", ",", "include_version", ":", "bool", "=", "True", ")", "->", "str", ":", "url", "=", "settings", ".", "get", "(", "\"static_url_...
b8b481770bcdb333a69afde5cce7eaa449128326
train
StaticFileHandler.parse_url_path
Converts a static URL path into a filesystem path. ``url_path`` is the path component of the URL with ``static_url_prefix`` removed. The return value should be filesystem path relative to ``static_path``. This is the inverse of `make_static_url`.
tornado/web.py
def parse_url_path(self, url_path: str) -> str: """Converts a static URL path into a filesystem path. ``url_path`` is the path component of the URL with ``static_url_prefix`` removed. The return value should be filesystem path relative to ``static_path``. This is the inverse o...
def parse_url_path(self, url_path: str) -> str: """Converts a static URL path into a filesystem path. ``url_path`` is the path component of the URL with ``static_url_prefix`` removed. The return value should be filesystem path relative to ``static_path``. This is the inverse o...
[ "Converts", "a", "static", "URL", "path", "into", "a", "filesystem", "path", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2953-L2964
[ "def", "parse_url_path", "(", "self", ",", "url_path", ":", "str", ")", "->", "str", ":", "if", "os", ".", "path", ".", "sep", "!=", "\"/\"", ":", "url_path", "=", "url_path", ".", "replace", "(", "\"/\"", ",", "os", ".", "path", ".", "sep", ")", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
StaticFileHandler.get_version
Generate the version string to be used in static URLs. ``settings`` is the `Application.settings` dictionary and ``path`` is the relative location of the requested asset on the filesystem. The returned value should be a string, or ``None`` if no version could be determined. .. ...
tornado/web.py
def get_version(cls, settings: Dict[str, Any], path: str) -> Optional[str]: """Generate the version string to be used in static URLs. ``settings`` is the `Application.settings` dictionary and ``path`` is the relative location of the requested asset on the filesystem. The returned value ...
def get_version(cls, settings: Dict[str, Any], path: str) -> Optional[str]: """Generate the version string to be used in static URLs. ``settings`` is the `Application.settings` dictionary and ``path`` is the relative location of the requested asset on the filesystem. The returned value ...
[ "Generate", "the", "version", "string", "to", "be", "used", "in", "static", "URLs", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2967-L2981
[ "def", "get_version", "(", "cls", ",", "settings", ":", "Dict", "[", "str", ",", "Any", "]", ",", "path", ":", "str", ")", "->", "Optional", "[", "str", "]", ":", "abs_path", "=", "cls", ".", "get_absolute_path", "(", "settings", "[", "\"static_path\""...
b8b481770bcdb333a69afde5cce7eaa449128326
train
UIModule.render_string
Renders a template and returns it as a string.
tornado/web.py
def render_string(self, path: str, **kwargs: Any) -> bytes: """Renders a template and returns it as a string.""" return self.handler.render_string(path, **kwargs)
def render_string(self, path: str, **kwargs: Any) -> bytes: """Renders a template and returns it as a string.""" return self.handler.render_string(path, **kwargs)
[ "Renders", "a", "template", "and", "returns", "it", "as", "a", "string", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L3241-L3243
[ "def", "render_string", "(", "self", ",", "path", ":", "str", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "bytes", ":", "return", "self", ".", "handler", ".", "render_string", "(", "path", ",", "*", "*", "kwargs", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
xhtml_escape
Escapes a string so it is valid within HTML or XML. Escapes the characters ``<``, ``>``, ``"``, ``'``, and ``&``. When used in attribute values the escaped strings must be enclosed in quotes. .. versionchanged:: 3.2 Added the single quote to the list of escaped characters.
tornado/escape.py
def xhtml_escape(value: Union[str, bytes]) -> str: """Escapes a string so it is valid within HTML or XML. Escapes the characters ``<``, ``>``, ``"``, ``'``, and ``&``. When used in attribute values the escaped strings must be enclosed in quotes. .. versionchanged:: 3.2 Added the single quo...
def xhtml_escape(value: Union[str, bytes]) -> str: """Escapes a string so it is valid within HTML or XML. Escapes the characters ``<``, ``>``, ``"``, ``'``, and ``&``. When used in attribute values the escaped strings must be enclosed in quotes. .. versionchanged:: 3.2 Added the single quo...
[ "Escapes", "a", "string", "so", "it", "is", "valid", "within", "HTML", "or", "XML", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/escape.py#L43-L56
[ "def", "xhtml_escape", "(", "value", ":", "Union", "[", "str", ",", "bytes", "]", ")", "->", "str", ":", "return", "_XHTML_ESCAPE_RE", ".", "sub", "(", "lambda", "match", ":", "_XHTML_ESCAPE_DICT", "[", "match", ".", "group", "(", "0", ")", "]", ",", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
xhtml_unescape
Un-escapes an XML-escaped string.
tornado/escape.py
def xhtml_unescape(value: Union[str, bytes]) -> str: """Un-escapes an XML-escaped string.""" return re.sub(r"&(#?)(\w+?);", _convert_entity, _unicode(value))
def xhtml_unescape(value: Union[str, bytes]) -> str: """Un-escapes an XML-escaped string.""" return re.sub(r"&(#?)(\w+?);", _convert_entity, _unicode(value))
[ "Un", "-", "escapes", "an", "XML", "-", "escaped", "string", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/escape.py#L59-L61
[ "def", "xhtml_unescape", "(", "value", ":", "Union", "[", "str", ",", "bytes", "]", ")", "->", "str", ":", "return", "re", ".", "sub", "(", "r\"&(#?)(\\w+?);\"", ",", "_convert_entity", ",", "_unicode", "(", "value", ")", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
json_decode
Returns Python objects for the given JSON string. Supports both `str` and `bytes` inputs.
tornado/escape.py
def json_decode(value: Union[str, bytes]) -> Any: """Returns Python objects for the given JSON string. Supports both `str` and `bytes` inputs. """ return json.loads(to_basestring(value))
def json_decode(value: Union[str, bytes]) -> Any: """Returns Python objects for the given JSON string. Supports both `str` and `bytes` inputs. """ return json.loads(to_basestring(value))
[ "Returns", "Python", "objects", "for", "the", "given", "JSON", "string", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/escape.py#L78-L83
[ "def", "json_decode", "(", "value", ":", "Union", "[", "str", ",", "bytes", "]", ")", "->", "Any", ":", "return", "json", ".", "loads", "(", "to_basestring", "(", "value", ")", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
url_escape
Returns a URL-encoded version of the given value. If ``plus`` is true (the default), spaces will be represented as "+" instead of "%20". This is appropriate for query strings but not for the path component of a URL. Note that this default is the reverse of Python's urllib module. .. versionadded...
tornado/escape.py
def url_escape(value: Union[str, bytes], plus: bool = True) -> str: """Returns a URL-encoded version of the given value. If ``plus`` is true (the default), spaces will be represented as "+" instead of "%20". This is appropriate for query strings but not for the path component of a URL. Note that this...
def url_escape(value: Union[str, bytes], plus: bool = True) -> str: """Returns a URL-encoded version of the given value. If ``plus`` is true (the default), spaces will be represented as "+" instead of "%20". This is appropriate for query strings but not for the path component of a URL. Note that this...
[ "Returns", "a", "URL", "-", "encoded", "version", "of", "the", "given", "value", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/escape.py#L91-L103
[ "def", "url_escape", "(", "value", ":", "Union", "[", "str", ",", "bytes", "]", ",", "plus", ":", "bool", "=", "True", ")", "->", "str", ":", "quote", "=", "urllib", ".", "parse", ".", "quote_plus", "if", "plus", "else", "urllib", ".", "parse", "."...
b8b481770bcdb333a69afde5cce7eaa449128326
train
url_unescape
Decodes the given value from a URL. The argument may be either a byte or unicode string. If encoding is None, the result will be a byte string. Otherwise, the result is a unicode string in the specified encoding. If ``plus`` is true (the default), plus signs will be interpreted as spaces (litera...
tornado/escape.py
def url_unescape( # noqa: F811 value: Union[str, bytes], encoding: Optional[str] = "utf-8", plus: bool = True ) -> Union[str, bytes]: """Decodes the given value from a URL. The argument may be either a byte or unicode string. If encoding is None, the result will be a byte string. Otherwise, the ...
def url_unescape( # noqa: F811 value: Union[str, bytes], encoding: Optional[str] = "utf-8", plus: bool = True ) -> Union[str, bytes]: """Decodes the given value from a URL. The argument may be either a byte or unicode string. If encoding is None, the result will be a byte string. Otherwise, the ...
[ "Decodes", "the", "given", "value", "from", "a", "URL", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/escape.py#L118-L144
[ "def", "url_unescape", "(", "# noqa: F811", "value", ":", "Union", "[", "str", ",", "bytes", "]", ",", "encoding", ":", "Optional", "[", "str", "]", "=", "\"utf-8\"", ",", "plus", ":", "bool", "=", "True", ")", "->", "Union", "[", "str", ",", "bytes"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
parse_qs_bytes
Parses a query string like urlparse.parse_qs, but returns the values as byte strings. Keys still become type str (interpreted as latin1 in python3!) because it's too painful to keep them as byte strings in python3 and in practice they're nearly always ascii anyway.
tornado/escape.py
def parse_qs_bytes( qs: str, keep_blank_values: bool = False, strict_parsing: bool = False ) -> Dict[str, List[bytes]]: """Parses a query string like urlparse.parse_qs, but returns the values as byte strings. Keys still become type str (interpreted as latin1 in python3!) because it's too painful to...
def parse_qs_bytes( qs: str, keep_blank_values: bool = False, strict_parsing: bool = False ) -> Dict[str, List[bytes]]: """Parses a query string like urlparse.parse_qs, but returns the values as byte strings. Keys still become type str (interpreted as latin1 in python3!) because it's too painful to...
[ "Parses", "a", "query", "string", "like", "urlparse", ".", "parse_qs", "but", "returns", "the", "values", "as", "byte", "strings", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/escape.py#L147-L165
[ "def", "parse_qs_bytes", "(", "qs", ":", "str", ",", "keep_blank_values", ":", "bool", "=", "False", ",", "strict_parsing", ":", "bool", "=", "False", ")", "->", "Dict", "[", "str", ",", "List", "[", "bytes", "]", "]", ":", "# This is gross, but python3 do...
b8b481770bcdb333a69afde5cce7eaa449128326
train
utf8
Converts a string argument to a byte string. If the argument is already a byte string or None, it is returned unchanged. Otherwise it must be a unicode string and is encoded as utf8.
tornado/escape.py
def utf8(value: Union[None, str, bytes]) -> Optional[bytes]: # noqa: F811 """Converts a string argument to a byte string. If the argument is already a byte string or None, it is returned unchanged. Otherwise it must be a unicode string and is encoded as utf8. """ if isinstance(value, _UTF8_TYPES):...
def utf8(value: Union[None, str, bytes]) -> Optional[bytes]: # noqa: F811 """Converts a string argument to a byte string. If the argument is already a byte string or None, it is returned unchanged. Otherwise it must be a unicode string and is encoded as utf8. """ if isinstance(value, _UTF8_TYPES):...
[ "Converts", "a", "string", "argument", "to", "a", "byte", "string", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/escape.py#L186-L196
[ "def", "utf8", "(", "value", ":", "Union", "[", "None", ",", "str", ",", "bytes", "]", ")", "->", "Optional", "[", "bytes", "]", ":", "# noqa: F811", "if", "isinstance", "(", "value", ",", "_UTF8_TYPES", ")", ":", "return", "value", "if", "not", "isi...
b8b481770bcdb333a69afde5cce7eaa449128326
train
to_unicode
Converts a string argument to a unicode string. If the argument is already a unicode string or None, it is returned unchanged. Otherwise it must be a byte string and is decoded as utf8.
tornado/escape.py
def to_unicode(value: Union[None, str, bytes]) -> Optional[str]: # noqa: F811 """Converts a string argument to a unicode string. If the argument is already a unicode string or None, it is returned unchanged. Otherwise it must be a byte string and is decoded as utf8. """ if isinstance(value, _TO_U...
def to_unicode(value: Union[None, str, bytes]) -> Optional[str]: # noqa: F811 """Converts a string argument to a unicode string. If the argument is already a unicode string or None, it is returned unchanged. Otherwise it must be a byte string and is decoded as utf8. """ if isinstance(value, _TO_U...
[ "Converts", "a", "string", "argument", "to", "a", "unicode", "string", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/escape.py#L217-L227
[ "def", "to_unicode", "(", "value", ":", "Union", "[", "None", ",", "str", ",", "bytes", "]", ")", "->", "Optional", "[", "str", "]", ":", "# noqa: F811", "if", "isinstance", "(", "value", ",", "_TO_UNICODE_TYPES", ")", ":", "return", "value", "if", "no...
b8b481770bcdb333a69afde5cce7eaa449128326
train
recursive_unicode
Walks a simple data structure, converting byte strings to unicode. Supports lists, tuples, and dictionaries.
tornado/escape.py
def recursive_unicode(obj: Any) -> Any: """Walks a simple data structure, converting byte strings to unicode. Supports lists, tuples, and dictionaries. """ if isinstance(obj, dict): return dict( (recursive_unicode(k), recursive_unicode(v)) for (k, v) in obj.items() ) eli...
def recursive_unicode(obj: Any) -> Any: """Walks a simple data structure, converting byte strings to unicode. Supports lists, tuples, and dictionaries. """ if isinstance(obj, dict): return dict( (recursive_unicode(k), recursive_unicode(v)) for (k, v) in obj.items() ) eli...
[ "Walks", "a", "simple", "data", "structure", "converting", "byte", "strings", "to", "unicode", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/escape.py#L240-L256
[ "def", "recursive_unicode", "(", "obj", ":", "Any", ")", "->", "Any", ":", "if", "isinstance", "(", "obj", ",", "dict", ")", ":", "return", "dict", "(", "(", "recursive_unicode", "(", "k", ")", ",", "recursive_unicode", "(", "v", ")", ")", "for", "("...
b8b481770bcdb333a69afde5cce7eaa449128326
train
linkify
Converts plain text into HTML with links. For example: ``linkify("Hello http://tornadoweb.org!")`` would return ``Hello <a href="http://tornadoweb.org">http://tornadoweb.org</a>!`` Parameters: * ``shorten``: Long urls will be shortened for display. * ``extra_params``: Extra text to include in th...
tornado/escape.py
def linkify( text: Union[str, bytes], shorten: bool = False, extra_params: Union[str, Callable[[str], str]] = "", require_protocol: bool = False, permitted_protocols: List[str] = ["http", "https"], ) -> str: """Converts plain text into HTML with links. For example: ``linkify("Hello http://t...
def linkify( text: Union[str, bytes], shorten: bool = False, extra_params: Union[str, Callable[[str], str]] = "", require_protocol: bool = False, permitted_protocols: List[str] = ["http", "https"], ) -> str: """Converts plain text into HTML with links. For example: ``linkify("Hello http://t...
[ "Converts", "plain", "text", "into", "HTML", "with", "links", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/escape.py#L273-L375
[ "def", "linkify", "(", "text", ":", "Union", "[", "str", ",", "bytes", "]", ",", "shorten", ":", "bool", "=", "False", ",", "extra_params", ":", "Union", "[", "str", ",", "Callable", "[", "[", "str", "]", ",", "str", "]", "]", "=", "\"\"", ",", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
IOLoop.current
Returns the current thread's `IOLoop`. If an `IOLoop` is currently running or has been marked as current by `make_current`, returns that instance. If there is no current `IOLoop` and ``instance`` is true, creates one. .. versionchanged:: 4.1 Added ``instance`` argument to c...
tornado/ioloop.py
def current(instance: bool = True) -> Optional["IOLoop"]: """Returns the current thread's `IOLoop`. If an `IOLoop` is currently running or has been marked as current by `make_current`, returns that instance. If there is no current `IOLoop` and ``instance`` is true, creates one. ...
def current(instance: bool = True) -> Optional["IOLoop"]: """Returns the current thread's `IOLoop`. If an `IOLoop` is currently running or has been marked as current by `make_current`, returns that instance. If there is no current `IOLoop` and ``instance`` is true, creates one. ...
[ "Returns", "the", "current", "thread", "s", "IOLoop", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L244-L279
[ "def", "current", "(", "instance", ":", "bool", "=", "True", ")", "->", "Optional", "[", "\"IOLoop\"", "]", ":", "try", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "except", "(", "RuntimeError", ",", "AssertionError", ")", ":", "if", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
IOLoop.clear_current
Clears the `IOLoop` for the current thread. Intended primarily for use by test frameworks in between tests. .. versionchanged:: 5.0 This method also clears the current `asyncio` event loop.
tornado/ioloop.py
def clear_current() -> None: """Clears the `IOLoop` for the current thread. Intended primarily for use by test frameworks in between tests. .. versionchanged:: 5.0 This method also clears the current `asyncio` event loop. """ old = IOLoop.current(instance=False) ...
def clear_current() -> None: """Clears the `IOLoop` for the current thread. Intended primarily for use by test frameworks in between tests. .. versionchanged:: 5.0 This method also clears the current `asyncio` event loop. """ old = IOLoop.current(instance=False) ...
[ "Clears", "the", "IOLoop", "for", "the", "current", "thread", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L301-L313
[ "def", "clear_current", "(", ")", "->", "None", ":", "old", "=", "IOLoop", ".", "current", "(", "instance", "=", "False", ")", "if", "old", "is", "not", "None", ":", "old", ".", "_clear_current_hook", "(", ")", "if", "asyncio", "is", "None", ":", "IO...
b8b481770bcdb333a69afde5cce7eaa449128326
train
IOLoop.add_handler
Registers the given handler to receive the given events for ``fd``. The ``fd`` argument may either be an integer file descriptor or a file-like object with a ``fileno()`` and ``close()`` method. The ``events`` argument is a bitwise or of the constants ``IOLoop.READ``, ``IOLoop.WRITE``,...
tornado/ioloop.py
def add_handler( # noqa: F811 self, fd: Union[int, _Selectable], handler: Callable[..., None], events: int ) -> None: """Registers the given handler to receive the given events for ``fd``. The ``fd`` argument may either be an integer file descriptor or a file-like object with a ``f...
def add_handler( # noqa: F811 self, fd: Union[int, _Selectable], handler: Callable[..., None], events: int ) -> None: """Registers the given handler to receive the given events for ``fd``. The ``fd`` argument may either be an integer file descriptor or a file-like object with a ``f...
[ "Registers", "the", "given", "handler", "to", "receive", "the", "given", "events", "for", "fd", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L382-L399
[ "def", "add_handler", "(", "# noqa: F811", "self", ",", "fd", ":", "Union", "[", "int", ",", "_Selectable", "]", ",", "handler", ":", "Callable", "[", "...", ",", "None", "]", ",", "events", ":", "int", ")", "->", "None", ":", "raise", "NotImplementedE...
b8b481770bcdb333a69afde5cce7eaa449128326
train
IOLoop._setup_logging
The IOLoop catches and logs exceptions, so it's important that log output be visible. However, python's default behavior for non-root loggers (prior to python 3.2) is to print an unhelpful "no handlers could be found" message rather than the actual log entry, so we must explicit...
tornado/ioloop.py
def _setup_logging(self) -> None: """The IOLoop catches and logs exceptions, so it's important that log output be visible. However, python's default behavior for non-root loggers (prior to python 3.2) is to print an unhelpful "no handlers could be found" message rather than the ...
def _setup_logging(self) -> None: """The IOLoop catches and logs exceptions, so it's important that log output be visible. However, python's default behavior for non-root loggers (prior to python 3.2) is to print an unhelpful "no handlers could be found" message rather than the ...
[ "The", "IOLoop", "catches", "and", "logs", "exceptions", "so", "it", "s", "important", "that", "log", "output", "be", "visible", ".", "However", "python", "s", "default", "behavior", "for", "non", "-", "root", "loggers", "(", "prior", "to", "python", "3", ...
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L427-L445
[ "def", "_setup_logging", "(", "self", ")", "->", "None", ":", "if", "not", "any", "(", "[", "logging", ".", "getLogger", "(", ")", ".", "handlers", ",", "logging", ".", "getLogger", "(", "\"tornado\"", ")", ".", "handlers", ",", "logging", ".", "getLog...
b8b481770bcdb333a69afde5cce7eaa449128326
train
IOLoop.run_sync
Starts the `IOLoop`, runs the given function, and stops the loop. The function must return either an awaitable object or ``None``. If the function returns an awaitable object, the `IOLoop` will run until the awaitable is resolved (and `run_sync()` will return the awaitable's result). If...
tornado/ioloop.py
def run_sync(self, func: Callable, timeout: float = None) -> Any: """Starts the `IOLoop`, runs the given function, and stops the loop. The function must return either an awaitable object or ``None``. If the function returns an awaitable object, the `IOLoop` will run until the awaitable ...
def run_sync(self, func: Callable, timeout: float = None) -> Any: """Starts the `IOLoop`, runs the given function, and stops the loop. The function must return either an awaitable object or ``None``. If the function returns an awaitable object, the `IOLoop` will run until the awaitable ...
[ "Starts", "the", "IOLoop", "runs", "the", "given", "function", "and", "stops", "the", "loop", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L460-L532
[ "def", "run_sync", "(", "self", ",", "func", ":", "Callable", ",", "timeout", ":", "float", "=", "None", ")", "->", "Any", ":", "future_cell", "=", "[", "None", "]", "# type: List[Optional[Future]]", "def", "run", "(", ")", "->", "None", ":", "try", ":...
b8b481770bcdb333a69afde5cce7eaa449128326
train
IOLoop.add_timeout
Runs the ``callback`` at the time ``deadline`` from the I/O loop. Returns an opaque handle that may be passed to `remove_timeout` to cancel. ``deadline`` may be a number denoting a time (on the same scale as `IOLoop.time`, normally `time.time`), or a `datetime.timedelta` object...
tornado/ioloop.py
def add_timeout( self, deadline: Union[float, datetime.timedelta], callback: Callable[..., None], *args: Any, **kwargs: Any ) -> object: """Runs the ``callback`` at the time ``deadline`` from the I/O loop. Returns an opaque handle that may be passed to ...
def add_timeout( self, deadline: Union[float, datetime.timedelta], callback: Callable[..., None], *args: Any, **kwargs: Any ) -> object: """Runs the ``callback`` at the time ``deadline`` from the I/O loop. Returns an opaque handle that may be passed to ...
[ "Runs", "the", "callback", "at", "the", "time", "deadline", "from", "the", "I", "/", "O", "loop", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L548-L587
[ "def", "add_timeout", "(", "self", ",", "deadline", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", ",", "callback", ":", "Callable", "[", "...", ",", "None", "]", ",", "*", "args", ":", "Any", ",", "*", "*", "kwargs", ":", "Any...
b8b481770bcdb333a69afde5cce7eaa449128326
train
IOLoop.call_later
Runs the ``callback`` after ``delay`` seconds have passed. Returns an opaque handle that may be passed to `remove_timeout` to cancel. Note that unlike the `asyncio` method of the same name, the returned object does not have a ``cancel()`` method. See `add_timeout` for comments on thre...
tornado/ioloop.py
def call_later( self, delay: float, callback: Callable[..., None], *args: Any, **kwargs: Any ) -> object: """Runs the ``callback`` after ``delay`` seconds have passed. Returns an opaque handle that may be passed to `remove_timeout` to cancel. Note that unlike the `asyncio` method o...
def call_later( self, delay: float, callback: Callable[..., None], *args: Any, **kwargs: Any ) -> object: """Runs the ``callback`` after ``delay`` seconds have passed. Returns an opaque handle that may be passed to `remove_timeout` to cancel. Note that unlike the `asyncio` method o...
[ "Runs", "the", "callback", "after", "delay", "seconds", "have", "passed", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L589-L602
[ "def", "call_later", "(", "self", ",", "delay", ":", "float", ",", "callback", ":", "Callable", "[", "...", ",", "None", "]", ",", "*", "args", ":", "Any", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "object", ":", "return", "self", ".", "cal...
b8b481770bcdb333a69afde5cce7eaa449128326
train
IOLoop.call_at
Runs the ``callback`` at the absolute time designated by ``when``. ``when`` must be a number using the same reference point as `IOLoop.time`. Returns an opaque handle that may be passed to `remove_timeout` to cancel. Note that unlike the `asyncio` method of the same name, the ...
tornado/ioloop.py
def call_at( self, when: float, callback: Callable[..., None], *args: Any, **kwargs: Any ) -> object: """Runs the ``callback`` at the absolute time designated by ``when``. ``when`` must be a number using the same reference point as `IOLoop.time`. Returns an opaque handle th...
def call_at( self, when: float, callback: Callable[..., None], *args: Any, **kwargs: Any ) -> object: """Runs the ``callback`` at the absolute time designated by ``when``. ``when`` must be a number using the same reference point as `IOLoop.time`. Returns an opaque handle th...
[ "Runs", "the", "callback", "at", "the", "absolute", "time", "designated", "by", "when", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L604-L620
[ "def", "call_at", "(", "self", ",", "when", ":", "float", ",", "callback", ":", "Callable", "[", "...", ",", "None", "]", ",", "*", "args", ":", "Any", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "object", ":", "return", "self", ".", "add_tim...
b8b481770bcdb333a69afde5cce7eaa449128326
train
IOLoop.spawn_callback
Calls the given callback on the next IOLoop iteration. As of Tornado 6.0, this method is equivalent to `add_callback`. .. versionadded:: 4.0
tornado/ioloop.py
def spawn_callback(self, callback: Callable, *args: Any, **kwargs: Any) -> None: """Calls the given callback on the next IOLoop iteration. As of Tornado 6.0, this method is equivalent to `add_callback`. .. versionadded:: 4.0 """ self.add_callback(callback, *args, **kwargs)
def spawn_callback(self, callback: Callable, *args: Any, **kwargs: Any) -> None: """Calls the given callback on the next IOLoop iteration. As of Tornado 6.0, this method is equivalent to `add_callback`. .. versionadded:: 4.0 """ self.add_callback(callback, *args, **kwargs)
[ "Calls", "the", "given", "callback", "on", "the", "next", "IOLoop", "iteration", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L656-L663
[ "def", "spawn_callback", "(", "self", ",", "callback", ":", "Callable", ",", "*", "args", ":", "Any", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "self", ".", "add_callback", "(", "callback", ",", "*", "args", ",", "*", "*", "kwarg...
b8b481770bcdb333a69afde5cce7eaa449128326
train
IOLoop.add_future
Schedules a callback on the ``IOLoop`` when the given `.Future` is finished. The callback is invoked with one argument, the `.Future`. This method only accepts `.Future` objects and not other awaitables (unlike most of Tornado where the two are interchangeable).
tornado/ioloop.py
def add_future( self, future: "Union[Future[_T], concurrent.futures.Future[_T]]", callback: Callable[["Future[_T]"], None], ) -> None: """Schedules a callback on the ``IOLoop`` when the given `.Future` is finished. The callback is invoked with one argument, the ...
def add_future( self, future: "Union[Future[_T], concurrent.futures.Future[_T]]", callback: Callable[["Future[_T]"], None], ) -> None: """Schedules a callback on the ``IOLoop`` when the given `.Future` is finished. The callback is invoked with one argument, the ...
[ "Schedules", "a", "callback", "on", "the", "IOLoop", "when", "the", "given", ".", "Future", "is", "finished", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L665-L698
[ "def", "add_future", "(", "self", ",", "future", ":", "\"Union[Future[_T], concurrent.futures.Future[_T]]\"", ",", "callback", ":", "Callable", "[", "[", "\"Future[_T]\"", "]", ",", "None", "]", ",", ")", "->", "None", ":", "if", "isinstance", "(", "future", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
IOLoop.run_in_executor
Runs a function in a ``concurrent.futures.Executor``. If ``executor`` is ``None``, the IO loop's default executor will be used. Use `functools.partial` to pass keyword arguments to ``func``. .. versionadded:: 5.0
tornado/ioloop.py
def run_in_executor( self, executor: Optional[concurrent.futures.Executor], func: Callable[..., _T], *args: Any ) -> Awaitable[_T]: """Runs a function in a ``concurrent.futures.Executor``. If ``executor`` is ``None``, the IO loop's default executor will be used. ...
def run_in_executor( self, executor: Optional[concurrent.futures.Executor], func: Callable[..., _T], *args: Any ) -> Awaitable[_T]: """Runs a function in a ``concurrent.futures.Executor``. If ``executor`` is ``None``, the IO loop's default executor will be used. ...
[ "Runs", "a", "function", "in", "a", "concurrent", ".", "futures", ".", "Executor", ".", "If", "executor", "is", "None", "the", "IO", "loop", "s", "default", "executor", "will", "be", "used", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L700-L726
[ "def", "run_in_executor", "(", "self", ",", "executor", ":", "Optional", "[", "concurrent", ".", "futures", ".", "Executor", "]", ",", "func", ":", "Callable", "[", "...", ",", "_T", "]", ",", "*", "args", ":", "Any", ")", "->", "Awaitable", "[", "_T...
b8b481770bcdb333a69afde5cce7eaa449128326
train
IOLoop._run_callback
Runs a callback with error handling. .. versionchanged:: 6.0 CancelledErrors are no longer logged.
tornado/ioloop.py
def _run_callback(self, callback: Callable[[], Any]) -> None: """Runs a callback with error handling. .. versionchanged:: 6.0 CancelledErrors are no longer logged. """ try: ret = callback() if ret is not None: from tornado import gen ...
def _run_callback(self, callback: Callable[[], Any]) -> None: """Runs a callback with error handling. .. versionchanged:: 6.0 CancelledErrors are no longer logged. """ try: ret = callback() if ret is not None: from tornado import gen ...
[ "Runs", "a", "callback", "with", "error", "handling", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L735-L763
[ "def", "_run_callback", "(", "self", ",", "callback", ":", "Callable", "[", "[", "]", ",", "Any", "]", ")", "->", "None", ":", "try", ":", "ret", "=", "callback", "(", ")", "if", "ret", "is", "not", "None", ":", "from", "tornado", "import", "gen", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
PeriodicCallback.start
Starts the timer.
tornado/ioloop.py
def start(self) -> None: """Starts the timer.""" # Looking up the IOLoop here allows to first instantiate the # PeriodicCallback in another thread, then start it using # IOLoop.add_callback(). self.io_loop = IOLoop.current() self._running = True self._next_timeout...
def start(self) -> None: """Starts the timer.""" # Looking up the IOLoop here allows to first instantiate the # PeriodicCallback in another thread, then start it using # IOLoop.add_callback(). self.io_loop = IOLoop.current() self._running = True self._next_timeout...
[ "Starts", "the", "timer", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L879-L887
[ "def", "start", "(", "self", ")", "->", "None", ":", "# Looking up the IOLoop here allows to first instantiate the", "# PeriodicCallback in another thread, then start it using", "# IOLoop.add_callback().", "self", ".", "io_loop", "=", "IOLoop", ".", "current", "(", ")", "self...
b8b481770bcdb333a69afde5cce7eaa449128326
train
PeriodicCallback.stop
Stops the timer.
tornado/ioloop.py
def stop(self) -> None: """Stops the timer.""" self._running = False if self._timeout is not None: self.io_loop.remove_timeout(self._timeout) self._timeout = None
def stop(self) -> None: """Stops the timer.""" self._running = False if self._timeout is not None: self.io_loop.remove_timeout(self._timeout) self._timeout = None
[ "Stops", "the", "timer", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/ioloop.py#L889-L894
[ "def", "stop", "(", "self", ")", "->", "None", ":", "self", ".", "_running", "=", "False", "if", "self", ".", "_timeout", "is", "not", "None", ":", "self", ".", "io_loop", ".", "remove_timeout", "(", "self", ".", "_timeout", ")", "self", ".", "_timeo...
b8b481770bcdb333a69afde5cce7eaa449128326
train
url_concat
Concatenate url and arguments regardless of whether url has existing query parameters. ``args`` may be either a dictionary or a list of key-value pairs (the latter allows for multiple values with the same key. >>> url_concat("http://example.com/foo", dict(c="d")) 'http://example.com/foo?c=d' >...
tornado/httputil.py
def url_concat( url: str, args: Union[ None, Dict[str, str], List[Tuple[str, str]], Tuple[Tuple[str, str], ...] ], ) -> str: """Concatenate url and arguments regardless of whether url has existing query parameters. ``args`` may be either a dictionary or a list of key-value pairs (th...
def url_concat( url: str, args: Union[ None, Dict[str, str], List[Tuple[str, str]], Tuple[Tuple[str, str], ...] ], ) -> str: """Concatenate url and arguments regardless of whether url has existing query parameters. ``args`` may be either a dictionary or a list of key-value pairs (th...
[ "Concatenate", "url", "and", "arguments", "regardless", "of", "whether", "url", "has", "existing", "query", "parameters", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L631-L675
[ "def", "url_concat", "(", "url", ":", "str", ",", "args", ":", "Union", "[", "None", ",", "Dict", "[", "str", ",", "str", "]", ",", "List", "[", "Tuple", "[", "str", ",", "str", "]", "]", ",", "Tuple", "[", "Tuple", "[", "str", ",", "str", "]...
b8b481770bcdb333a69afde5cce7eaa449128326
train
_parse_request_range
Parses a Range header. Returns either ``None`` or tuple ``(start, end)``. Note that while the HTTP headers use inclusive byte positions, this method returns indexes suitable for use in slices. >>> start, end = _parse_request_range("bytes=1-2") >>> start, end (1, 3) >>> [0, 1, 2, 3, 4][star...
tornado/httputil.py
def _parse_request_range( range_header: str ) -> Optional[Tuple[Optional[int], Optional[int]]]: """Parses a Range header. Returns either ``None`` or tuple ``(start, end)``. Note that while the HTTP headers use inclusive byte positions, this method returns indexes suitable for use in slices. >>...
def _parse_request_range( range_header: str ) -> Optional[Tuple[Optional[int], Optional[int]]]: """Parses a Range header. Returns either ``None`` or tuple ``(start, end)``. Note that while the HTTP headers use inclusive byte positions, this method returns indexes suitable for use in slices. >>...
[ "Parses", "a", "Range", "header", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L692-L740
[ "def", "_parse_request_range", "(", "range_header", ":", "str", ")", "->", "Optional", "[", "Tuple", "[", "Optional", "[", "int", "]", ",", "Optional", "[", "int", "]", "]", "]", ":", "unit", ",", "_", ",", "value", "=", "range_header", ".", "partition...
b8b481770bcdb333a69afde5cce7eaa449128326
train
_get_content_range
Returns a suitable Content-Range header: >>> print(_get_content_range(None, 1, 4)) bytes 0-0/4 >>> print(_get_content_range(1, 3, 4)) bytes 1-2/4 >>> print(_get_content_range(None, None, 4)) bytes 0-3/4
tornado/httputil.py
def _get_content_range(start: Optional[int], end: Optional[int], total: int) -> str: """Returns a suitable Content-Range header: >>> print(_get_content_range(None, 1, 4)) bytes 0-0/4 >>> print(_get_content_range(1, 3, 4)) bytes 1-2/4 >>> print(_get_content_range(None, None, 4)) bytes 0-3/4 ...
def _get_content_range(start: Optional[int], end: Optional[int], total: int) -> str: """Returns a suitable Content-Range header: >>> print(_get_content_range(None, 1, 4)) bytes 0-0/4 >>> print(_get_content_range(1, 3, 4)) bytes 1-2/4 >>> print(_get_content_range(None, None, 4)) bytes 0-3/4 ...
[ "Returns", "a", "suitable", "Content", "-", "Range", "header", ":" ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L743-L755
[ "def", "_get_content_range", "(", "start", ":", "Optional", "[", "int", "]", ",", "end", ":", "Optional", "[", "int", "]", ",", "total", ":", "int", ")", "->", "str", ":", "start", "=", "start", "or", "0", "end", "=", "(", "end", "or", "total", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
parse_body_arguments
Parses a form request body. Supports ``application/x-www-form-urlencoded`` and ``multipart/form-data``. The ``content_type`` parameter should be a string and ``body`` should be a byte string. The ``arguments`` and ``files`` parameters are dictionaries that will be updated with the parsed contents...
tornado/httputil.py
def parse_body_arguments( content_type: str, body: bytes, arguments: Dict[str, List[bytes]], files: Dict[str, List[HTTPFile]], headers: HTTPHeaders = None, ) -> None: """Parses a form request body. Supports ``application/x-www-form-urlencoded`` and ``multipart/form-data``. The ``conten...
def parse_body_arguments( content_type: str, body: bytes, arguments: Dict[str, List[bytes]], files: Dict[str, List[HTTPFile]], headers: HTTPHeaders = None, ) -> None: """Parses a form request body. Supports ``application/x-www-form-urlencoded`` and ``multipart/form-data``. The ``conten...
[ "Parses", "a", "form", "request", "body", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L765-L810
[ "def", "parse_body_arguments", "(", "content_type", ":", "str", ",", "body", ":", "bytes", ",", "arguments", ":", "Dict", "[", "str", ",", "List", "[", "bytes", "]", "]", ",", "files", ":", "Dict", "[", "str", ",", "List", "[", "HTTPFile", "]", "]", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
parse_multipart_form_data
Parses a ``multipart/form-data`` body. The ``boundary`` and ``data`` parameters are both byte strings. The dictionaries given in the arguments and files parameters will be updated with the contents of the body. .. versionchanged:: 5.1 Now recognizes non-ASCII filenames in RFC 2231/5987 ...
tornado/httputil.py
def parse_multipart_form_data( boundary: bytes, data: bytes, arguments: Dict[str, List[bytes]], files: Dict[str, List[HTTPFile]], ) -> None: """Parses a ``multipart/form-data`` body. The ``boundary`` and ``data`` parameters are both byte strings. The dictionaries given in the arguments and ...
def parse_multipart_form_data( boundary: bytes, data: bytes, arguments: Dict[str, List[bytes]], files: Dict[str, List[HTTPFile]], ) -> None: """Parses a ``multipart/form-data`` body. The ``boundary`` and ``data`` parameters are both byte strings. The dictionaries given in the arguments and ...
[ "Parses", "a", "multipart", "/", "form", "-", "data", "body", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L813-L868
[ "def", "parse_multipart_form_data", "(", "boundary", ":", "bytes", ",", "data", ":", "bytes", ",", "arguments", ":", "Dict", "[", "str", ",", "List", "[", "bytes", "]", "]", ",", "files", ":", "Dict", "[", "str", ",", "List", "[", "HTTPFile", "]", "]...
b8b481770bcdb333a69afde5cce7eaa449128326
train
format_timestamp
Formats a timestamp in the format used by HTTP. The argument may be a numeric timestamp as returned by `time.time`, a time tuple as returned by `time.gmtime`, or a `datetime.datetime` object. >>> format_timestamp(1359312200) 'Sun, 27 Jan 2013 18:43:20 GMT'
tornado/httputil.py
def format_timestamp( ts: Union[int, float, tuple, time.struct_time, datetime.datetime] ) -> str: """Formats a timestamp in the format used by HTTP. The argument may be a numeric timestamp as returned by `time.time`, a time tuple as returned by `time.gmtime`, or a `datetime.datetime` object. >...
def format_timestamp( ts: Union[int, float, tuple, time.struct_time, datetime.datetime] ) -> str: """Formats a timestamp in the format used by HTTP. The argument may be a numeric timestamp as returned by `time.time`, a time tuple as returned by `time.gmtime`, or a `datetime.datetime` object. >...
[ "Formats", "a", "timestamp", "in", "the", "format", "used", "by", "HTTP", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L871-L891
[ "def", "format_timestamp", "(", "ts", ":", "Union", "[", "int", ",", "float", ",", "tuple", ",", "time", ".", "struct_time", ",", "datetime", ".", "datetime", "]", ")", "->", "str", ":", "if", "isinstance", "(", "ts", ",", "(", "int", ",", "float", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
parse_request_start_line
Returns a (method, path, version) tuple for an HTTP 1.x request line. The response is a `collections.namedtuple`. >>> parse_request_start_line("GET /foo HTTP/1.1") RequestStartLine(method='GET', path='/foo', version='HTTP/1.1')
tornado/httputil.py
def parse_request_start_line(line: str) -> RequestStartLine: """Returns a (method, path, version) tuple for an HTTP 1.x request line. The response is a `collections.namedtuple`. >>> parse_request_start_line("GET /foo HTTP/1.1") RequestStartLine(method='GET', path='/foo', version='HTTP/1.1') """ ...
def parse_request_start_line(line: str) -> RequestStartLine: """Returns a (method, path, version) tuple for an HTTP 1.x request line. The response is a `collections.namedtuple`. >>> parse_request_start_line("GET /foo HTTP/1.1") RequestStartLine(method='GET', path='/foo', version='HTTP/1.1') """ ...
[ "Returns", "a", "(", "method", "path", "version", ")", "tuple", "for", "an", "HTTP", "1", ".", "x", "request", "line", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L899-L917
[ "def", "parse_request_start_line", "(", "line", ":", "str", ")", "->", "RequestStartLine", ":", "try", ":", "method", ",", "path", ",", "version", "=", "line", ".", "split", "(", "\" \"", ")", "except", "ValueError", ":", "# https://tools.ietf.org/html/rfc7230#s...
b8b481770bcdb333a69afde5cce7eaa449128326
train
parse_response_start_line
Returns a (version, code, reason) tuple for an HTTP 1.x response line. The response is a `collections.namedtuple`. >>> parse_response_start_line("HTTP/1.1 200 OK") ResponseStartLine(version='HTTP/1.1', code=200, reason='OK')
tornado/httputil.py
def parse_response_start_line(line: str) -> ResponseStartLine: """Returns a (version, code, reason) tuple for an HTTP 1.x response line. The response is a `collections.namedtuple`. >>> parse_response_start_line("HTTP/1.1 200 OK") ResponseStartLine(version='HTTP/1.1', code=200, reason='OK') """ ...
def parse_response_start_line(line: str) -> ResponseStartLine: """Returns a (version, code, reason) tuple for an HTTP 1.x response line. The response is a `collections.namedtuple`. >>> parse_response_start_line("HTTP/1.1 200 OK") ResponseStartLine(version='HTTP/1.1', code=200, reason='OK') """ ...
[ "Returns", "a", "(", "version", "code", "reason", ")", "tuple", "for", "an", "HTTP", "1", ".", "x", "response", "line", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L925-L937
[ "def", "parse_response_start_line", "(", "line", ":", "str", ")", "->", "ResponseStartLine", ":", "line", "=", "native_str", "(", "line", ")", "match", "=", "re", ".", "match", "(", "\"(HTTP/1.[0-9]) ([0-9]+) ([^\\r]*)\"", ",", "line", ")", "if", "not", "match...
b8b481770bcdb333a69afde5cce7eaa449128326
train
_parse_header
r"""Parse a Content-type like header. Return the main content-type and a dictionary of options. >>> d = "form-data; foo=\"b\\\\a\\\"r\"; file*=utf-8''T%C3%A4st" >>> ct, d = _parse_header(d) >>> ct 'form-data' >>> d['file'] == r'T\u00e4st'.encode('ascii').decode('unicode_escape') True >...
tornado/httputil.py
def _parse_header(line: str) -> Tuple[str, Dict[str, str]]: r"""Parse a Content-type like header. Return the main content-type and a dictionary of options. >>> d = "form-data; foo=\"b\\\\a\\\"r\"; file*=utf-8''T%C3%A4st" >>> ct, d = _parse_header(d) >>> ct 'form-data' >>> d['file'] == r'T\...
def _parse_header(line: str) -> Tuple[str, Dict[str, str]]: r"""Parse a Content-type like header. Return the main content-type and a dictionary of options. >>> d = "form-data; foo=\"b\\\\a\\\"r\"; file*=utf-8''T%C3%A4st" >>> ct, d = _parse_header(d) >>> ct 'form-data' >>> d['file'] == r'T\...
[ "r", "Parse", "a", "Content", "-", "type", "like", "header", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L961-L993
[ "def", "_parse_header", "(", "line", ":", "str", ")", "->", "Tuple", "[", "str", ",", "Dict", "[", "str", ",", "str", "]", "]", ":", "parts", "=", "_parseparam", "(", "\";\"", "+", "line", ")", "key", "=", "next", "(", "parts", ")", "# decode_param...
b8b481770bcdb333a69afde5cce7eaa449128326
train
_encode_header
Inverse of _parse_header. >>> _encode_header('permessage-deflate', ... {'client_max_window_bits': 15, 'client_no_context_takeover': None}) 'permessage-deflate; client_max_window_bits=15; client_no_context_takeover'
tornado/httputil.py
def _encode_header(key: str, pdict: Dict[str, str]) -> str: """Inverse of _parse_header. >>> _encode_header('permessage-deflate', ... {'client_max_window_bits': 15, 'client_no_context_takeover': None}) 'permessage-deflate; client_max_window_bits=15; client_no_context_takeover' """ if not pd...
def _encode_header(key: str, pdict: Dict[str, str]) -> str: """Inverse of _parse_header. >>> _encode_header('permessage-deflate', ... {'client_max_window_bits': 15, 'client_no_context_takeover': None}) 'permessage-deflate; client_max_window_bits=15; client_no_context_takeover' """ if not pd...
[ "Inverse", "of", "_parse_header", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L996-L1013
[ "def", "_encode_header", "(", "key", ":", "str", ",", "pdict", ":", "Dict", "[", "str", ",", "str", "]", ")", "->", "str", ":", "if", "not", "pdict", ":", "return", "key", "out", "=", "[", "key", "]", "# Sort the parameters just to make it easy to test.", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
encode_username_password
Encodes a username/password pair in the format used by HTTP auth. The return value is a byte string in the form ``username:password``. .. versionadded:: 5.1
tornado/httputil.py
def encode_username_password( username: Union[str, bytes], password: Union[str, bytes] ) -> bytes: """Encodes a username/password pair in the format used by HTTP auth. The return value is a byte string in the form ``username:password``. .. versionadded:: 5.1 """ if isinstance(username, unicode...
def encode_username_password( username: Union[str, bytes], password: Union[str, bytes] ) -> bytes: """Encodes a username/password pair in the format used by HTTP auth. The return value is a byte string in the form ``username:password``. .. versionadded:: 5.1 """ if isinstance(username, unicode...
[ "Encodes", "a", "username", "/", "password", "pair", "in", "the", "format", "used", "by", "HTTP", "auth", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L1016-L1029
[ "def", "encode_username_password", "(", "username", ":", "Union", "[", "str", ",", "bytes", "]", ",", "password", ":", "Union", "[", "str", ",", "bytes", "]", ")", "->", "bytes", ":", "if", "isinstance", "(", "username", ",", "unicode_type", ")", ":", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
split_host_and_port
Returns ``(host, port)`` tuple from ``netloc``. Returned ``port`` will be ``None`` if not present. .. versionadded:: 4.1
tornado/httputil.py
def split_host_and_port(netloc: str) -> Tuple[str, Optional[int]]: """Returns ``(host, port)`` tuple from ``netloc``. Returned ``port`` will be ``None`` if not present. .. versionadded:: 4.1 """ match = re.match(r"^(.+):(\d+)$", netloc) if match: host = match.group(1) port = in...
def split_host_and_port(netloc: str) -> Tuple[str, Optional[int]]: """Returns ``(host, port)`` tuple from ``netloc``. Returned ``port`` will be ``None`` if not present. .. versionadded:: 4.1 """ match = re.match(r"^(.+):(\d+)$", netloc) if match: host = match.group(1) port = in...
[ "Returns", "(", "host", "port", ")", "tuple", "from", "netloc", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L1039-L1053
[ "def", "split_host_and_port", "(", "netloc", ":", "str", ")", "->", "Tuple", "[", "str", ",", "Optional", "[", "int", "]", "]", ":", "match", "=", "re", ".", "match", "(", "r\"^(.+):(\\d+)$\"", ",", "netloc", ")", "if", "match", ":", "host", "=", "ma...
b8b481770bcdb333a69afde5cce7eaa449128326
train
qs_to_qsl
Generator converting a result of ``parse_qs`` back to name-value pairs. .. versionadded:: 5.0
tornado/httputil.py
def qs_to_qsl(qs: Dict[str, List[AnyStr]]) -> Iterable[Tuple[str, AnyStr]]: """Generator converting a result of ``parse_qs`` back to name-value pairs. .. versionadded:: 5.0 """ for k, vs in qs.items(): for v in vs: yield (k, v)
def qs_to_qsl(qs: Dict[str, List[AnyStr]]) -> Iterable[Tuple[str, AnyStr]]: """Generator converting a result of ``parse_qs`` back to name-value pairs. .. versionadded:: 5.0 """ for k, vs in qs.items(): for v in vs: yield (k, v)
[ "Generator", "converting", "a", "result", "of", "parse_qs", "back", "to", "name", "-", "value", "pairs", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L1056-L1063
[ "def", "qs_to_qsl", "(", "qs", ":", "Dict", "[", "str", ",", "List", "[", "AnyStr", "]", "]", ")", "->", "Iterable", "[", "Tuple", "[", "str", ",", "AnyStr", "]", "]", ":", "for", "k", ",", "vs", "in", "qs", ".", "items", "(", ")", ":", "for"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
_unquote_cookie
Handle double quotes and escaping in cookie values. This method is copied verbatim from the Python 3.5 standard library (http.cookies._unquote) so we don't have to depend on non-public interfaces.
tornado/httputil.py
def _unquote_cookie(s: str) -> str: """Handle double quotes and escaping in cookie values. This method is copied verbatim from the Python 3.5 standard library (http.cookies._unquote) so we don't have to depend on non-public interfaces. """ # If there aren't any doublequotes, # then there ca...
def _unquote_cookie(s: str) -> str: """Handle double quotes and escaping in cookie values. This method is copied verbatim from the Python 3.5 standard library (http.cookies._unquote) so we don't have to depend on non-public interfaces. """ # If there aren't any doublequotes, # then there ca...
[ "Handle", "double", "quotes", "and", "escaping", "in", "cookie", "values", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L1071-L1118
[ "def", "_unquote_cookie", "(", "s", ":", "str", ")", "->", "str", ":", "# If there aren't any doublequotes,", "# then there can't be any special characters. See RFC 2109.", "if", "s", "is", "None", "or", "len", "(", "s", ")", "<", "2", ":", "return", "s", "if", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
parse_cookie
Parse a ``Cookie`` HTTP header into a dict of name/value pairs. This function attempts to mimic browser cookie parsing behavior; it specifically does not follow any of the cookie-related RFCs (because browsers don't either). The algorithm used is identical to that used by Django version 1.9.10. ....
tornado/httputil.py
def parse_cookie(cookie: str) -> Dict[str, str]: """Parse a ``Cookie`` HTTP header into a dict of name/value pairs. This function attempts to mimic browser cookie parsing behavior; it specifically does not follow any of the cookie-related RFCs (because browsers don't either). The algorithm used is...
def parse_cookie(cookie: str) -> Dict[str, str]: """Parse a ``Cookie`` HTTP header into a dict of name/value pairs. This function attempts to mimic browser cookie parsing behavior; it specifically does not follow any of the cookie-related RFCs (because browsers don't either). The algorithm used is...
[ "Parse", "a", "Cookie", "HTTP", "header", "into", "a", "dict", "of", "name", "/", "value", "pairs", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L1121-L1144
[ "def", "parse_cookie", "(", "cookie", ":", "str", ")", "->", "Dict", "[", "str", ",", "str", "]", ":", "cookiedict", "=", "{", "}", "for", "chunk", "in", "cookie", ".", "split", "(", "str", "(", "\";\"", ")", ")", ":", "if", "str", "(", "\"=\"", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTPHeaders.add
Adds a new value for the given key.
tornado/httputil.py
def add(self, name: str, value: str) -> None: """Adds a new value for the given key.""" norm_name = _normalized_headers[name] self._last_key = norm_name if norm_name in self: self._dict[norm_name] = ( native_str(self[norm_name]) + "," + native_str(value) ...
def add(self, name: str, value: str) -> None: """Adds a new value for the given key.""" norm_name = _normalized_headers[name] self._last_key = norm_name if norm_name in self: self._dict[norm_name] = ( native_str(self[norm_name]) + "," + native_str(value) ...
[ "Adds", "a", "new", "value", "for", "the", "given", "key", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L162-L172
[ "def", "add", "(", "self", ",", "name", ":", "str", ",", "value", ":", "str", ")", "->", "None", ":", "norm_name", "=", "_normalized_headers", "[", "name", "]", "self", ".", "_last_key", "=", "norm_name", "if", "norm_name", "in", "self", ":", "self", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTPHeaders.get_list
Returns all values for the given header as a list.
tornado/httputil.py
def get_list(self, name: str) -> List[str]: """Returns all values for the given header as a list.""" norm_name = _normalized_headers[name] return self._as_list.get(norm_name, [])
def get_list(self, name: str) -> List[str]: """Returns all values for the given header as a list.""" norm_name = _normalized_headers[name] return self._as_list.get(norm_name, [])
[ "Returns", "all", "values", "for", "the", "given", "header", "as", "a", "list", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L174-L177
[ "def", "get_list", "(", "self", ",", "name", ":", "str", ")", "->", "List", "[", "str", "]", ":", "norm_name", "=", "_normalized_headers", "[", "name", "]", "return", "self", ".", "_as_list", ".", "get", "(", "norm_name", ",", "[", "]", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTPHeaders.get_all
Returns an iterable of all (name, value) pairs. If a header has multiple values, multiple pairs will be returned with the same name.
tornado/httputil.py
def get_all(self) -> Iterable[Tuple[str, str]]: """Returns an iterable of all (name, value) pairs. If a header has multiple values, multiple pairs will be returned with the same name. """ for name, values in self._as_list.items(): for value in values: ...
def get_all(self) -> Iterable[Tuple[str, str]]: """Returns an iterable of all (name, value) pairs. If a header has multiple values, multiple pairs will be returned with the same name. """ for name, values in self._as_list.items(): for value in values: ...
[ "Returns", "an", "iterable", "of", "all", "(", "name", "value", ")", "pairs", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L179-L187
[ "def", "get_all", "(", "self", ")", "->", "Iterable", "[", "Tuple", "[", "str", ",", "str", "]", "]", ":", "for", "name", ",", "values", "in", "self", ".", "_as_list", ".", "items", "(", ")", ":", "for", "value", "in", "values", ":", "yield", "("...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTPHeaders.parse_line
Updates the dictionary with a single header line. >>> h = HTTPHeaders() >>> h.parse_line("Content-Type: text/html") >>> h.get('content-type') 'text/html'
tornado/httputil.py
def parse_line(self, line: str) -> None: """Updates the dictionary with a single header line. >>> h = HTTPHeaders() >>> h.parse_line("Content-Type: text/html") >>> h.get('content-type') 'text/html' """ if line[0].isspace(): # continuation of a multi-l...
def parse_line(self, line: str) -> None: """Updates the dictionary with a single header line. >>> h = HTTPHeaders() >>> h.parse_line("Content-Type: text/html") >>> h.get('content-type') 'text/html' """ if line[0].isspace(): # continuation of a multi-l...
[ "Updates", "the", "dictionary", "with", "a", "single", "header", "line", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L189-L209
[ "def", "parse_line", "(", "self", ",", "line", ":", "str", ")", "->", "None", ":", "if", "line", "[", "0", "]", ".", "isspace", "(", ")", ":", "# continuation of a multi-line header", "if", "self", ".", "_last_key", "is", "None", ":", "raise", "HTTPInput...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTPHeaders.parse
Returns a dictionary from HTTP header text. >>> h = HTTPHeaders.parse("Content-Type: text/html\\r\\nContent-Length: 42\\r\\n") >>> sorted(h.items()) [('Content-Length', '42'), ('Content-Type', 'text/html')] .. versionchanged:: 5.1 Raises `HTTPInputError` on malformed header...
tornado/httputil.py
def parse(cls, headers: str) -> "HTTPHeaders": """Returns a dictionary from HTTP header text. >>> h = HTTPHeaders.parse("Content-Type: text/html\\r\\nContent-Length: 42\\r\\n") >>> sorted(h.items()) [('Content-Length', '42'), ('Content-Type', 'text/html')] .. versionchanged:: 5...
def parse(cls, headers: str) -> "HTTPHeaders": """Returns a dictionary from HTTP header text. >>> h = HTTPHeaders.parse("Content-Type: text/html\\r\\nContent-Length: 42\\r\\n") >>> sorted(h.items()) [('Content-Length', '42'), ('Content-Type', 'text/html')] .. versionchanged:: 5...
[ "Returns", "a", "dictionary", "from", "HTTP", "header", "text", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L212-L229
[ "def", "parse", "(", "cls", ",", "headers", ":", "str", ")", "->", "\"HTTPHeaders\"", ":", "h", "=", "cls", "(", ")", "for", "line", "in", "_CRLF_RE", ".", "split", "(", "headers", ")", ":", "if", "line", ":", "h", ".", "parse_line", "(", "line", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTPServerRequest.cookies
A dictionary of ``http.cookies.Morsel`` objects.
tornado/httputil.py
def cookies(self) -> Dict[str, http.cookies.Morsel]: """A dictionary of ``http.cookies.Morsel`` objects.""" if not hasattr(self, "_cookies"): self._cookies = http.cookies.SimpleCookie() if "Cookie" in self.headers: try: parsed = parse_cookie(se...
def cookies(self) -> Dict[str, http.cookies.Morsel]: """A dictionary of ``http.cookies.Morsel`` objects.""" if not hasattr(self, "_cookies"): self._cookies = http.cookies.SimpleCookie() if "Cookie" in self.headers: try: parsed = parse_cookie(se...
[ "A", "dictionary", "of", "http", ".", "cookies", ".", "Morsel", "objects", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L410-L428
[ "def", "cookies", "(", "self", ")", "->", "Dict", "[", "str", ",", "http", ".", "cookies", ".", "Morsel", "]", ":", "if", "not", "hasattr", "(", "self", ",", "\"_cookies\"", ")", ":", "self", ".", "_cookies", "=", "http", ".", "cookies", ".", "Simp...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTPServerRequest.request_time
Returns the amount of time it took for this request to execute.
tornado/httputil.py
def request_time(self) -> float: """Returns the amount of time it took for this request to execute.""" if self._finish_time is None: return time.time() - self._start_time else: return self._finish_time - self._start_time
def request_time(self) -> float: """Returns the amount of time it took for this request to execute.""" if self._finish_time is None: return time.time() - self._start_time else: return self._finish_time - self._start_time
[ "Returns", "the", "amount", "of", "time", "it", "took", "for", "this", "request", "to", "execute", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L434-L439
[ "def", "request_time", "(", "self", ")", "->", "float", ":", "if", "self", ".", "_finish_time", "is", "None", ":", "return", "time", ".", "time", "(", ")", "-", "self", ".", "_start_time", "else", ":", "return", "self", ".", "_finish_time", "-", "self"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTPServerRequest.get_ssl_certificate
Returns the client's SSL certificate, if any. To use client certificates, the HTTPServer's `ssl.SSLContext.verify_mode` field must be set, e.g.:: ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) ssl_ctx.load_cert_chain("foo.crt", "foo.key") ssl_ctx.load...
tornado/httputil.py
def get_ssl_certificate( self, binary_form: bool = False ) -> Union[None, Dict, bytes]: """Returns the client's SSL certificate, if any. To use client certificates, the HTTPServer's `ssl.SSLContext.verify_mode` field must be set, e.g.:: ssl_ctx = ssl.create_default_cont...
def get_ssl_certificate( self, binary_form: bool = False ) -> Union[None, Dict, bytes]: """Returns the client's SSL certificate, if any. To use client certificates, the HTTPServer's `ssl.SSLContext.verify_mode` field must be set, e.g.:: ssl_ctx = ssl.create_default_cont...
[ "Returns", "the", "client", "s", "SSL", "certificate", "if", "any", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httputil.py#L441-L470
[ "def", "get_ssl_certificate", "(", "self", ",", "binary_form", ":", "bool", "=", "False", ")", "->", "Union", "[", "None", ",", "Dict", ",", "bytes", "]", ":", "try", ":", "if", "self", ".", "connection", "is", "None", ":", "return", "None", "# TODO: a...
b8b481770bcdb333a69afde5cce7eaa449128326
train
bind_sockets
Creates listening sockets bound to the given port and address. Returns a list of socket objects (multiple sockets are returned if the given address maps to multiple IP addresses, which is most common for mixed IPv4 and IPv6 use). Address may be either an IP address or hostname. If it's a hostname, ...
tornado/netutil.py
def bind_sockets( port: int, address: str = None, family: socket.AddressFamily = socket.AF_UNSPEC, backlog: int = _DEFAULT_BACKLOG, flags: int = None, reuse_port: bool = False, ) -> List[socket.socket]: """Creates listening sockets bound to the given port and address. Returns a list of ...
def bind_sockets( port: int, address: str = None, family: socket.AddressFamily = socket.AF_UNSPEC, backlog: int = _DEFAULT_BACKLOG, flags: int = None, reuse_port: bool = False, ) -> List[socket.socket]: """Creates listening sockets bound to the given port and address. Returns a list of ...
[ "Creates", "listening", "sockets", "bound", "to", "the", "given", "port", "and", "address", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/netutil.py#L68-L178
[ "def", "bind_sockets", "(", "port", ":", "int", ",", "address", ":", "str", "=", "None", ",", "family", ":", "socket", ".", "AddressFamily", "=", "socket", ".", "AF_UNSPEC", ",", "backlog", ":", "int", "=", "_DEFAULT_BACKLOG", ",", "flags", ":", "int", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
add_accept_handler
Adds an `.IOLoop` event handler to accept new connections on ``sock``. When a connection is accepted, ``callback(connection, address)`` will be run (``connection`` is a socket object, and ``address`` is the address of the other end of the connection). Note that this signature is different from the ``c...
tornado/netutil.py
def add_accept_handler( sock: socket.socket, callback: Callable[[socket.socket, Any], None] ) -> Callable[[], None]: """Adds an `.IOLoop` event handler to accept new connections on ``sock``. When a connection is accepted, ``callback(connection, address)`` will be run (``connection`` is a socket object,...
def add_accept_handler( sock: socket.socket, callback: Callable[[socket.socket, Any], None] ) -> Callable[[], None]: """Adds an `.IOLoop` event handler to accept new connections on ``sock``. When a connection is accepted, ``callback(connection, address)`` will be run (``connection`` is a socket object,...
[ "Adds", "an", ".", "IOLoop", "event", "handler", "to", "accept", "new", "connections", "on", "sock", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/netutil.py#L220-L280
[ "def", "add_accept_handler", "(", "sock", ":", "socket", ".", "socket", ",", "callback", ":", "Callable", "[", "[", "socket", ".", "socket", ",", "Any", "]", ",", "None", "]", ")", "->", "Callable", "[", "[", "]", ",", "None", "]", ":", "io_loop", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
is_valid_ip
Returns ``True`` if the given string is a well-formed IP address. Supports IPv4 and IPv6.
tornado/netutil.py
def is_valid_ip(ip: str) -> bool: """Returns ``True`` if the given string is a well-formed IP address. Supports IPv4 and IPv6. """ if not ip or "\x00" in ip: # getaddrinfo resolves empty strings to localhost, and truncates # on zero bytes. return False try: res = soc...
def is_valid_ip(ip: str) -> bool: """Returns ``True`` if the given string is a well-formed IP address. Supports IPv4 and IPv6. """ if not ip or "\x00" in ip: # getaddrinfo resolves empty strings to localhost, and truncates # on zero bytes. return False try: res = soc...
[ "Returns", "True", "if", "the", "given", "string", "is", "a", "well", "-", "formed", "IP", "address", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/netutil.py#L283-L301
[ "def", "is_valid_ip", "(", "ip", ":", "str", ")", "->", "bool", ":", "if", "not", "ip", "or", "\"\\x00\"", "in", "ip", ":", "# getaddrinfo resolves empty strings to localhost, and truncates", "# on zero bytes.", "return", "False", "try", ":", "res", "=", "socket",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
ssl_options_to_context
Try to convert an ``ssl_options`` dictionary to an `~ssl.SSLContext` object. The ``ssl_options`` dictionary contains keywords to be passed to `ssl.wrap_socket`. In Python 2.7.9+, `ssl.SSLContext` objects can be used instead. This function converts the dict form to its `~ssl.SSLContext` equivalent...
tornado/netutil.py
def ssl_options_to_context( ssl_options: Union[Dict[str, Any], ssl.SSLContext] ) -> ssl.SSLContext: """Try to convert an ``ssl_options`` dictionary to an `~ssl.SSLContext` object. The ``ssl_options`` dictionary contains keywords to be passed to `ssl.wrap_socket`. In Python 2.7.9+, `ssl.SSLContext`...
def ssl_options_to_context( ssl_options: Union[Dict[str, Any], ssl.SSLContext] ) -> ssl.SSLContext: """Try to convert an ``ssl_options`` dictionary to an `~ssl.SSLContext` object. The ``ssl_options`` dictionary contains keywords to be passed to `ssl.wrap_socket`. In Python 2.7.9+, `ssl.SSLContext`...
[ "Try", "to", "convert", "an", "ssl_options", "dictionary", "to", "an", "~ssl", ".", "SSLContext", "object", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/netutil.py#L552-L588
[ "def", "ssl_options_to_context", "(", "ssl_options", ":", "Union", "[", "Dict", "[", "str", ",", "Any", "]", ",", "ssl", ".", "SSLContext", "]", ")", "->", "ssl", ".", "SSLContext", ":", "if", "isinstance", "(", "ssl_options", ",", "ssl", ".", "SSLContex...
b8b481770bcdb333a69afde5cce7eaa449128326
train
ssl_wrap_socket
Returns an ``ssl.SSLSocket`` wrapping the given socket. ``ssl_options`` may be either an `ssl.SSLContext` object or a dictionary (as accepted by `ssl_options_to_context`). Additional keyword arguments are passed to ``wrap_socket`` (either the `~ssl.SSLContext` method or the `ssl` module function as ...
tornado/netutil.py
def ssl_wrap_socket( socket: socket.socket, ssl_options: Union[Dict[str, Any], ssl.SSLContext], server_hostname: str = None, **kwargs: Any ) -> ssl.SSLSocket: """Returns an ``ssl.SSLSocket`` wrapping the given socket. ``ssl_options`` may be either an `ssl.SSLContext` object or a dictionary ...
def ssl_wrap_socket( socket: socket.socket, ssl_options: Union[Dict[str, Any], ssl.SSLContext], server_hostname: str = None, **kwargs: Any ) -> ssl.SSLSocket: """Returns an ``ssl.SSLSocket`` wrapping the given socket. ``ssl_options`` may be either an `ssl.SSLContext` object or a dictionary ...
[ "Returns", "an", "ssl", ".", "SSLSocket", "wrapping", "the", "given", "socket", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/netutil.py#L591-L614
[ "def", "ssl_wrap_socket", "(", "socket", ":", "socket", ".", "socket", ",", "ssl_options", ":", "Union", "[", "Dict", "[", "str", ",", "Any", "]", ",", "ssl", ".", "SSLContext", "]", ",", "server_hostname", ":", "str", "=", "None", ",", "*", "*", "kw...
b8b481770bcdb333a69afde5cce7eaa449128326
train
run_on_executor
Decorator to run a synchronous method asynchronously on an executor. The decorated method may be called with a ``callback`` keyword argument and returns a future. The executor to be used is determined by the ``executor`` attributes of ``self``. To use a different attribute name, pass a keyword arg...
tornado/concurrent.py
def run_on_executor(*args: Any, **kwargs: Any) -> Callable: """Decorator to run a synchronous method asynchronously on an executor. The decorated method may be called with a ``callback`` keyword argument and returns a future. The executor to be used is determined by the ``executor`` attributes of ...
def run_on_executor(*args: Any, **kwargs: Any) -> Callable: """Decorator to run a synchronous method asynchronously on an executor. The decorated method may be called with a ``callback`` keyword argument and returns a future. The executor to be used is determined by the ``executor`` attributes of ...
[ "Decorator", "to", "run", "a", "synchronous", "method", "asynchronously", "on", "an", "executor", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/concurrent.py#L74-L135
[ "def", "run_on_executor", "(", "*", "args", ":", "Any", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "Callable", ":", "# Fully type-checking decorators is tricky, and this one is", "# discouraged anyway so it doesn't have all the generic magic.", "def", "run_on_executor_de...
b8b481770bcdb333a69afde5cce7eaa449128326
train
chain_future
Chain two futures together so that when one completes, so does the other. The result (success or failure) of ``a`` will be copied to ``b``, unless ``b`` has already been completed or cancelled by the time ``a`` finishes. .. versionchanged:: 5.0 Now accepts both Tornado/asyncio `Future` objects and...
tornado/concurrent.py
def chain_future(a: "Future[_T]", b: "Future[_T]") -> None: """Chain two futures together so that when one completes, so does the other. The result (success or failure) of ``a`` will be copied to ``b``, unless ``b`` has already been completed or cancelled by the time ``a`` finishes. .. versionchanged:...
def chain_future(a: "Future[_T]", b: "Future[_T]") -> None: """Chain two futures together so that when one completes, so does the other. The result (success or failure) of ``a`` will be copied to ``b``, unless ``b`` has already been completed or cancelled by the time ``a`` finishes. .. versionchanged:...
[ "Chain", "two", "futures", "together", "so", "that", "when", "one", "completes", "so", "does", "the", "other", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/concurrent.py#L141-L171
[ "def", "chain_future", "(", "a", ":", "\"Future[_T]\"", ",", "b", ":", "\"Future[_T]\"", ")", "->", "None", ":", "def", "copy", "(", "future", ":", "\"Future[_T]\"", ")", "->", "None", ":", "assert", "future", "is", "a", "if", "b", ".", "done", "(", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
future_set_exception_unless_cancelled
Set the given ``exc`` as the `Future`'s exception. If the Future is already canceled, logs the exception instead. If this logging is not desired, the caller should explicitly check the state of the Future and call ``Future.set_exception`` instead of this wrapper. Avoids ``asyncio.InvalidStateError...
tornado/concurrent.py
def future_set_exception_unless_cancelled( future: "Union[futures.Future[_T], Future[_T]]", exc: BaseException ) -> None: """Set the given ``exc`` as the `Future`'s exception. If the Future is already canceled, logs the exception instead. If this logging is not desired, the caller should explicitly che...
def future_set_exception_unless_cancelled( future: "Union[futures.Future[_T], Future[_T]]", exc: BaseException ) -> None: """Set the given ``exc`` as the `Future`'s exception. If the Future is already canceled, logs the exception instead. If this logging is not desired, the caller should explicitly che...
[ "Set", "the", "given", "exc", "as", "the", "Future", "s", "exception", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/concurrent.py#L188-L207
[ "def", "future_set_exception_unless_cancelled", "(", "future", ":", "\"Union[futures.Future[_T], Future[_T]]\"", ",", "exc", ":", "BaseException", ")", "->", "None", ":", "if", "not", "future", ".", "cancelled", "(", ")", ":", "future", ".", "set_exception", "(", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
future_set_exc_info
Set the given ``exc_info`` as the `Future`'s exception. Understands both `asyncio.Future` and the extensions in older versions of Tornado to enable better tracebacks on Python 2. .. versionadded:: 5.0 .. versionchanged:: 6.0 If the future is already cancelled, this function is a no-op. ...
tornado/concurrent.py
def future_set_exc_info( future: "Union[futures.Future[_T], Future[_T]]", exc_info: Tuple[ Optional[type], Optional[BaseException], Optional[types.TracebackType] ], ) -> None: """Set the given ``exc_info`` as the `Future`'s exception. Understands both `asyncio.Future` and the extensions in ...
def future_set_exc_info( future: "Union[futures.Future[_T], Future[_T]]", exc_info: Tuple[ Optional[type], Optional[BaseException], Optional[types.TracebackType] ], ) -> None: """Set the given ``exc_info`` as the `Future`'s exception. Understands both `asyncio.Future` and the extensions in ...
[ "Set", "the", "given", "exc_info", "as", "the", "Future", "s", "exception", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/concurrent.py#L210-L231
[ "def", "future_set_exc_info", "(", "future", ":", "\"Union[futures.Future[_T], Future[_T]]\"", ",", "exc_info", ":", "Tuple", "[", "Optional", "[", "type", "]", ",", "Optional", "[", "BaseException", "]", ",", "Optional", "[", "types", ".", "TracebackType", "]", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
future_add_done_callback
Arrange to call ``callback`` when ``future`` is complete. ``callback`` is invoked with one argument, the ``future``. If ``future`` is already done, ``callback`` is invoked immediately. This may differ from the behavior of ``Future.add_done_callback``, which makes no such guarantee. .. versionadde...
tornado/concurrent.py
def future_add_done_callback( # noqa: F811 future: "Union[futures.Future[_T], Future[_T]]", callback: Callable[..., None] ) -> None: """Arrange to call ``callback`` when ``future`` is complete. ``callback`` is invoked with one argument, the ``future``. If ``future`` is already done, ``callback`` is i...
def future_add_done_callback( # noqa: F811 future: "Union[futures.Future[_T], Future[_T]]", callback: Callable[..., None] ) -> None: """Arrange to call ``callback`` when ``future`` is complete. ``callback`` is invoked with one argument, the ``future``. If ``future`` is already done, ``callback`` is i...
[ "Arrange", "to", "call", "callback", "when", "future", "is", "complete", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/concurrent.py#L248-L264
[ "def", "future_add_done_callback", "(", "# noqa: F811", "future", ":", "\"Union[futures.Future[_T], Future[_T]]\"", ",", "callback", ":", "Callable", "[", "...", ",", "None", "]", ")", "->", "None", ":", "if", "future", ".", "done", "(", ")", ":", "callback", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
filter_whitespace
Transform whitespace in ``text`` according to ``mode``. Available modes are: * ``all``: Return all whitespace unmodified. * ``single``: Collapse consecutive whitespace with a single whitespace character, preserving newlines. * ``oneline``: Collapse all runs of whitespace into a single space ...
tornado/template.py
def filter_whitespace(mode: str, text: str) -> str: """Transform whitespace in ``text`` according to ``mode``. Available modes are: * ``all``: Return all whitespace unmodified. * ``single``: Collapse consecutive whitespace with a single whitespace character, preserving newlines. * ``oneline`...
def filter_whitespace(mode: str, text: str) -> str: """Transform whitespace in ``text`` according to ``mode``. Available modes are: * ``all``: Return all whitespace unmodified. * ``single``: Collapse consecutive whitespace with a single whitespace character, preserving newlines. * ``oneline`...
[ "Transform", "whitespace", "in", "text", "according", "to", "mode", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/template.py#L226-L248
[ "def", "filter_whitespace", "(", "mode", ":", "str", ",", "text", ":", "str", ")", "->", "str", ":", "if", "mode", "==", "\"all\"", ":", "return", "text", "elif", "mode", "==", "\"single\"", ":", "text", "=", "re", ".", "sub", "(", "r\"([\\t ]+)\"", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Template.generate
Generate this template with the given arguments.
tornado/template.py
def generate(self, **kwargs: Any) -> bytes: """Generate this template with the given arguments.""" namespace = { "escape": escape.xhtml_escape, "xhtml_escape": escape.xhtml_escape, "url_escape": escape.url_escape, "json_encode": escape.json_encode, ...
def generate(self, **kwargs: Any) -> bytes: """Generate this template with the given arguments.""" namespace = { "escape": escape.xhtml_escape, "xhtml_escape": escape.xhtml_escape, "url_escape": escape.url_escape, "json_encode": escape.json_encode, ...
[ "Generate", "this", "template", "with", "the", "given", "arguments", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/template.py#L336-L361
[ "def", "generate", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "bytes", ":", "namespace", "=", "{", "\"escape\"", ":", "escape", ".", "xhtml_escape", ",", "\"xhtml_escape\"", ":", "escape", ".", "xhtml_escape", ",", "\"url_escape\"", ":", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseLoader.load
Loads a template.
tornado/template.py
def load(self, name: str, parent_path: str = None) -> Template: """Loads a template.""" name = self.resolve_path(name, parent_path=parent_path) with self.lock: if name not in self.templates: self.templates[name] = self._create_template(name) return self.te...
def load(self, name: str, parent_path: str = None) -> Template: """Loads a template.""" name = self.resolve_path(name, parent_path=parent_path) with self.lock: if name not in self.templates: self.templates[name] = self._create_template(name) return self.te...
[ "Loads", "a", "template", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/template.py#L440-L446
[ "def", "load", "(", "self", ",", "name", ":", "str", ",", "parent_path", ":", "str", "=", "None", ")", "->", "Template", ":", "name", "=", "self", ".", "resolve_path", "(", "name", ",", "parent_path", "=", "parent_path", ")", "with", "self", ".", "lo...
b8b481770bcdb333a69afde5cce7eaa449128326
train
coroutine
Decorator for asynchronous generators. For compatibility with older versions of Python, coroutines may also "return" by raising the special exception `Return(value) <Return>`. Functions with this decorator return a `.Future`. .. warning:: When exceptions occur inside a coroutine, the exce...
tornado/gen.py
def coroutine( func: Callable[..., "Generator[Any, Any, _T]"] ) -> Callable[..., "Future[_T]"]: """Decorator for asynchronous generators. For compatibility with older versions of Python, coroutines may also "return" by raising the special exception `Return(value) <Return>`. Functions with this...
def coroutine( func: Callable[..., "Generator[Any, Any, _T]"] ) -> Callable[..., "Future[_T]"]: """Decorator for asynchronous generators. For compatibility with older versions of Python, coroutines may also "return" by raising the special exception `Return(value) <Return>`. Functions with this...
[ "Decorator", "for", "asynchronous", "generators", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/gen.py#L156-L245
[ "def", "coroutine", "(", "func", ":", "Callable", "[", "...", ",", "\"Generator[Any, Any, _T]\"", "]", ")", "->", "Callable", "[", "...", ",", "\"Future[_T]\"", "]", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args...
b8b481770bcdb333a69afde5cce7eaa449128326
train
multi
Runs multiple asynchronous operations in parallel. ``children`` may either be a list or a dict whose values are yieldable objects. ``multi()`` returns a new yieldable object that resolves to a parallel structure containing their results. If ``children`` is a list, the result is a list of results in...
tornado/gen.py
def multi( children: Union[List[_Yieldable], Dict[Any, _Yieldable]], quiet_exceptions: "Union[Type[Exception], Tuple[Type[Exception], ...]]" = (), ) -> "Union[Future[List], Future[Dict]]": """Runs multiple asynchronous operations in parallel. ``children`` may either be a list or a dict whose values are...
def multi( children: Union[List[_Yieldable], Dict[Any, _Yieldable]], quiet_exceptions: "Union[Type[Exception], Tuple[Type[Exception], ...]]" = (), ) -> "Union[Future[List], Future[Dict]]": """Runs multiple asynchronous operations in parallel. ``children`` may either be a list or a dict whose values are...
[ "Runs", "multiple", "asynchronous", "operations", "in", "parallel", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/gen.py#L409-L457
[ "def", "multi", "(", "children", ":", "Union", "[", "List", "[", "_Yieldable", "]", ",", "Dict", "[", "Any", ",", "_Yieldable", "]", "]", ",", "quiet_exceptions", ":", "\"Union[Type[Exception], Tuple[Type[Exception], ...]]\"", "=", "(", ")", ",", ")", "->", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
multi_future
Wait for multiple asynchronous futures in parallel. Since Tornado 6.0, this function is exactly the same as `multi`. .. versionadded:: 4.0 .. versionchanged:: 4.2 If multiple ``Futures`` fail, any exceptions after the first (which is raised) will be logged. Added the ``quiet_exceptions`` ...
tornado/gen.py
def multi_future( children: Union[List[_Yieldable], Dict[Any, _Yieldable]], quiet_exceptions: "Union[Type[Exception], Tuple[Type[Exception], ...]]" = (), ) -> "Union[Future[List], Future[Dict]]": """Wait for multiple asynchronous futures in parallel. Since Tornado 6.0, this function is exactly the same...
def multi_future( children: Union[List[_Yieldable], Dict[Any, _Yieldable]], quiet_exceptions: "Union[Type[Exception], Tuple[Type[Exception], ...]]" = (), ) -> "Union[Future[List], Future[Dict]]": """Wait for multiple asynchronous futures in parallel. Since Tornado 6.0, this function is exactly the same...
[ "Wait", "for", "multiple", "asynchronous", "futures", "in", "parallel", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/gen.py#L463-L523
[ "def", "multi_future", "(", "children", ":", "Union", "[", "List", "[", "_Yieldable", "]", ",", "Dict", "[", "Any", ",", "_Yieldable", "]", "]", ",", "quiet_exceptions", ":", "\"Union[Type[Exception], Tuple[Type[Exception], ...]]\"", "=", "(", ")", ",", ")", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
maybe_future
Converts ``x`` into a `.Future`. If ``x`` is already a `.Future`, it is simply returned; otherwise it is wrapped in a new `.Future`. This is suitable for use as ``result = yield gen.maybe_future(f())`` when you don't know whether ``f()`` returns a `.Future` or not. .. deprecated:: 4.3 This...
tornado/gen.py
def maybe_future(x: Any) -> Future: """Converts ``x`` into a `.Future`. If ``x`` is already a `.Future`, it is simply returned; otherwise it is wrapped in a new `.Future`. This is suitable for use as ``result = yield gen.maybe_future(f())`` when you don't know whether ``f()`` returns a `.Future` o...
def maybe_future(x: Any) -> Future: """Converts ``x`` into a `.Future`. If ``x`` is already a `.Future`, it is simply returned; otherwise it is wrapped in a new `.Future`. This is suitable for use as ``result = yield gen.maybe_future(f())`` when you don't know whether ``f()`` returns a `.Future` o...
[ "Converts", "x", "into", "a", ".", "Future", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/gen.py#L526-L544
[ "def", "maybe_future", "(", "x", ":", "Any", ")", "->", "Future", ":", "if", "is_future", "(", "x", ")", ":", "return", "x", "else", ":", "fut", "=", "_create_future", "(", ")", "fut", ".", "set_result", "(", "x", ")", "return", "fut" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
with_timeout
Wraps a `.Future` (or other yieldable object) in a timeout. Raises `tornado.util.TimeoutError` if the input future does not complete before ``timeout``, which may be specified in any form allowed by `.IOLoop.add_timeout` (i.e. a `datetime.timedelta` or an absolute time relative to `.IOLoop.time`) ...
tornado/gen.py
def with_timeout( timeout: Union[float, datetime.timedelta], future: _Yieldable, quiet_exceptions: "Union[Type[Exception], Tuple[Type[Exception], ...]]" = (), ) -> Future: """Wraps a `.Future` (or other yieldable object) in a timeout. Raises `tornado.util.TimeoutError` if the input future does not ...
def with_timeout( timeout: Union[float, datetime.timedelta], future: _Yieldable, quiet_exceptions: "Union[Type[Exception], Tuple[Type[Exception], ...]]" = (), ) -> Future: """Wraps a `.Future` (or other yieldable object) in a timeout. Raises `tornado.util.TimeoutError` if the input future does not ...
[ "Wraps", "a", ".", "Future", "(", "or", "other", "yieldable", "object", ")", "in", "a", "timeout", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/gen.py#L547-L616
[ "def", "with_timeout", "(", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", ",", "future", ":", "_Yieldable", ",", "quiet_exceptions", ":", "\"Union[Type[Exception], Tuple[Type[Exception], ...]]\"", "=", "(", ")", ",", ")", "->", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
sleep
Return a `.Future` that resolves after the given number of seconds. When used with ``yield`` in a coroutine, this is a non-blocking analogue to `time.sleep` (which should not be used in coroutines because it is blocking):: yield gen.sleep(0.5) Note that calling this function on its own does n...
tornado/gen.py
def sleep(duration: float) -> "Future[None]": """Return a `.Future` that resolves after the given number of seconds. When used with ``yield`` in a coroutine, this is a non-blocking analogue to `time.sleep` (which should not be used in coroutines because it is blocking):: yield gen.sleep(0.5) ...
def sleep(duration: float) -> "Future[None]": """Return a `.Future` that resolves after the given number of seconds. When used with ``yield`` in a coroutine, this is a non-blocking analogue to `time.sleep` (which should not be used in coroutines because it is blocking):: yield gen.sleep(0.5) ...
[ "Return", "a", ".", "Future", "that", "resolves", "after", "the", "given", "number", "of", "seconds", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/gen.py#L619-L637
[ "def", "sleep", "(", "duration", ":", "float", ")", "->", "\"Future[None]\"", ":", "f", "=", "_create_future", "(", ")", "IOLoop", ".", "current", "(", ")", ".", "call_later", "(", "duration", ",", "lambda", ":", "future_set_result_unless_cancelled", "(", "f...
b8b481770bcdb333a69afde5cce7eaa449128326
train
convert_yielded
Convert a yielded object into a `.Future`. The default implementation accepts lists, dictionaries, and Futures. This has the side effect of starting any coroutines that did not start themselves, similar to `asyncio.ensure_future`. If the `~functools.singledispatch` library is available, this function ...
tornado/gen.py
def convert_yielded(yielded: _Yieldable) -> Future: """Convert a yielded object into a `.Future`. The default implementation accepts lists, dictionaries, and Futures. This has the side effect of starting any coroutines that did not start themselves, similar to `asyncio.ensure_future`. If the `~fun...
def convert_yielded(yielded: _Yieldable) -> Future: """Convert a yielded object into a `.Future`. The default implementation accepts lists, dictionaries, and Futures. This has the side effect of starting any coroutines that did not start themselves, similar to `asyncio.ensure_future`. If the `~fun...
[ "Convert", "a", "yielded", "object", "into", "a", ".", "Future", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/gen.py#L808-L836
[ "def", "convert_yielded", "(", "yielded", ":", "_Yieldable", ")", "->", "Future", ":", "if", "yielded", "is", "None", "or", "yielded", "is", "moment", ":", "return", "moment", "elif", "yielded", "is", "_null_future", ":", "return", "_null_future", "elif", "i...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WaitIterator.next
Returns a `.Future` that will yield the next available result. Note that this `.Future` will not be the same object as any of the inputs.
tornado/gen.py
def next(self) -> Future: """Returns a `.Future` that will yield the next available result. Note that this `.Future` will not be the same object as any of the inputs. """ self._running_future = Future() if self._finished: self._return_result(self._finished.p...
def next(self) -> Future: """Returns a `.Future` that will yield the next available result. Note that this `.Future` will not be the same object as any of the inputs. """ self._running_future = Future() if self._finished: self._return_result(self._finished.p...
[ "Returns", "a", ".", "Future", "that", "will", "yield", "the", "next", "available", "result", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/gen.py#L369-L380
[ "def", "next", "(", "self", ")", "->", "Future", ":", "self", ".", "_running_future", "=", "Future", "(", ")", "if", "self", ".", "_finished", ":", "self", ".", "_return_result", "(", "self", ".", "_finished", ".", "popleft", "(", ")", ")", "return", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Runner.run
Starts or resumes the generator, running until it reaches a yield point that is not ready.
tornado/gen.py
def run(self) -> None: """Starts or resumes the generator, running until it reaches a yield point that is not ready. """ if self.running or self.finished: return try: self.running = True while True: future = self.future ...
def run(self) -> None: """Starts or resumes the generator, running until it reaches a yield point that is not ready. """ if self.running or self.finished: return try: self.running = True while True: future = self.future ...
[ "Starts", "or", "resumes", "the", "generator", "running", "until", "it", "reaches", "a", "yield", "point", "that", "is", "not", "ready", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/gen.py#L710-L762
[ "def", "run", "(", "self", ")", "->", "None", ":", "if", "self", ".", "running", "or", "self", ".", "finished", ":", "return", "try", ":", "self", ".", "running", "=", "True", "while", "True", ":", "future", "=", "self", ".", "future", "if", "futur...
b8b481770bcdb333a69afde5cce7eaa449128326
train
_StreamBuffer.append
Append the given piece of data (should be a buffer-compatible object).
tornado/iostream.py
def append(self, data: Union[bytes, bytearray, memoryview]) -> None: """ Append the given piece of data (should be a buffer-compatible object). """ size = len(data) if size > self._large_buf_threshold: if not isinstance(data, memoryview): data = memory...
def append(self, data: Union[bytes, bytearray, memoryview]) -> None: """ Append the given piece of data (should be a buffer-compatible object). """ size = len(data) if size > self._large_buf_threshold: if not isinstance(data, memoryview): data = memory...
[ "Append", "the", "given", "piece", "of", "data", "(", "should", "be", "a", "buffer", "-", "compatible", "object", ")", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L159-L179
[ "def", "append", "(", "self", ",", "data", ":", "Union", "[", "bytes", ",", "bytearray", ",", "memoryview", "]", ")", "->", "None", ":", "size", "=", "len", "(", "data", ")", "if", "size", ">", "self", ".", "_large_buf_threshold", ":", "if", "not", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
_StreamBuffer.peek
Get a view over at most ``size`` bytes (possibly fewer) at the current buffer position.
tornado/iostream.py
def peek(self, size: int) -> memoryview: """ Get a view over at most ``size`` bytes (possibly fewer) at the current buffer position. """ assert size > 0 try: is_memview, b = self._buffers[0] except IndexError: return memoryview(b"") ...
def peek(self, size: int) -> memoryview: """ Get a view over at most ``size`` bytes (possibly fewer) at the current buffer position. """ assert size > 0 try: is_memview, b = self._buffers[0] except IndexError: return memoryview(b"") ...
[ "Get", "a", "view", "over", "at", "most", "size", "bytes", "(", "possibly", "fewer", ")", "at", "the", "current", "buffer", "position", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L181-L196
[ "def", "peek", "(", "self", ",", "size", ":", "int", ")", "->", "memoryview", ":", "assert", "size", ">", "0", "try", ":", "is_memview", ",", "b", "=", "self", ".", "_buffers", "[", "0", "]", "except", "IndexError", ":", "return", "memoryview", "(", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
_StreamBuffer.advance
Advance the current buffer position by ``size`` bytes.
tornado/iostream.py
def advance(self, size: int) -> None: """ Advance the current buffer position by ``size`` bytes. """ assert 0 < size <= self._size self._size -= size pos = self._first_pos buffers = self._buffers while buffers and size > 0: is_large, b = buffe...
def advance(self, size: int) -> None: """ Advance the current buffer position by ``size`` bytes. """ assert 0 < size <= self._size self._size -= size pos = self._first_pos buffers = self._buffers while buffers and size > 0: is_large, b = buffe...
[ "Advance", "the", "current", "buffer", "position", "by", "size", "bytes", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L198-L226
[ "def", "advance", "(", "self", ",", "size", ":", "int", ")", "->", "None", ":", "assert", "0", "<", "size", "<=", "self", ".", "_size", "self", ".", "_size", "-=", "size", "pos", "=", "self", ".", "_first_pos", "buffers", "=", "self", ".", "_buffer...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseIOStream.read_until_regex
Asynchronously read until we have matched the given regex. The result includes the data that matches the regex and anything that came before it. If ``max_bytes`` is not None, the connection will be closed if more than ``max_bytes`` bytes have been read and the regex is not sati...
tornado/iostream.py
def read_until_regex(self, regex: bytes, max_bytes: int = None) -> Awaitable[bytes]: """Asynchronously read until we have matched the given regex. The result includes the data that matches the regex and anything that came before it. If ``max_bytes`` is not None, the connection will be ...
def read_until_regex(self, regex: bytes, max_bytes: int = None) -> Awaitable[bytes]: """Asynchronously read until we have matched the given regex. The result includes the data that matches the regex and anything that came before it. If ``max_bytes`` is not None, the connection will be ...
[ "Asynchronously", "read", "until", "we", "have", "matched", "the", "given", "regex", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L349-L384
[ "def", "read_until_regex", "(", "self", ",", "regex", ":", "bytes", ",", "max_bytes", ":", "int", "=", "None", ")", "->", "Awaitable", "[", "bytes", "]", ":", "future", "=", "self", ".", "_start_read", "(", ")", "self", ".", "_read_regex", "=", "re", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseIOStream.read_until
Asynchronously read until we have found the given delimiter. The result includes all the data read including the delimiter. If ``max_bytes`` is not None, the connection will be closed if more than ``max_bytes`` bytes have been read and the delimiter is not found. .. versioncha...
tornado/iostream.py
def read_until(self, delimiter: bytes, max_bytes: int = None) -> Awaitable[bytes]: """Asynchronously read until we have found the given delimiter. The result includes all the data read including the delimiter. If ``max_bytes`` is not None, the connection will be closed if more than ``m...
def read_until(self, delimiter: bytes, max_bytes: int = None) -> Awaitable[bytes]: """Asynchronously read until we have found the given delimiter. The result includes all the data read including the delimiter. If ``max_bytes`` is not None, the connection will be closed if more than ``m...
[ "Asynchronously", "read", "until", "we", "have", "found", "the", "given", "delimiter", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L386-L417
[ "def", "read_until", "(", "self", ",", "delimiter", ":", "bytes", ",", "max_bytes", ":", "int", "=", "None", ")", "->", "Awaitable", "[", "bytes", "]", ":", "future", "=", "self", ".", "_start_read", "(", ")", "self", ".", "_read_delimiter", "=", "deli...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseIOStream.read_bytes
Asynchronously read a number of bytes. If ``partial`` is true, data is returned as soon as we have any bytes to return (but never more than ``num_bytes``) .. versionchanged:: 4.0 Added the ``partial`` argument. The callback argument is now optional and a `.Future` will...
tornado/iostream.py
def read_bytes(self, num_bytes: int, partial: bool = False) -> Awaitable[bytes]: """Asynchronously read a number of bytes. If ``partial`` is true, data is returned as soon as we have any bytes to return (but never more than ``num_bytes``) .. versionchanged:: 4.0 Added the `...
def read_bytes(self, num_bytes: int, partial: bool = False) -> Awaitable[bytes]: """Asynchronously read a number of bytes. If ``partial`` is true, data is returned as soon as we have any bytes to return (but never more than ``num_bytes``) .. versionchanged:: 4.0 Added the `...
[ "Asynchronously", "read", "a", "number", "of", "bytes", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L419-L445
[ "def", "read_bytes", "(", "self", ",", "num_bytes", ":", "int", ",", "partial", ":", "bool", "=", "False", ")", "->", "Awaitable", "[", "bytes", "]", ":", "future", "=", "self", ".", "_start_read", "(", ")", "assert", "isinstance", "(", "num_bytes", ",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseIOStream.read_into
Asynchronously read a number of bytes. ``buf`` must be a writable buffer into which data will be read. If ``partial`` is true, the callback is run as soon as any bytes have been read. Otherwise, it is run when the ``buf`` has been entirely filled with read data. .. versionadd...
tornado/iostream.py
def read_into(self, buf: bytearray, partial: bool = False) -> Awaitable[int]: """Asynchronously read a number of bytes. ``buf`` must be a writable buffer into which data will be read. If ``partial`` is true, the callback is run as soon as any bytes have been read. Otherwise, it is run...
def read_into(self, buf: bytearray, partial: bool = False) -> Awaitable[int]: """Asynchronously read a number of bytes. ``buf`` must be a writable buffer into which data will be read. If ``partial`` is true, the callback is run as soon as any bytes have been read. Otherwise, it is run...
[ "Asynchronously", "read", "a", "number", "of", "bytes", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L447-L494
[ "def", "read_into", "(", "self", ",", "buf", ":", "bytearray", ",", "partial", ":", "bool", "=", "False", ")", "->", "Awaitable", "[", "int", "]", ":", "future", "=", "self", ".", "_start_read", "(", ")", "# First copy data already in read buffer", "availabl...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseIOStream.read_until_close
Asynchronously reads all data from the socket until it is closed. This will buffer all available data until ``max_buffer_size`` is reached. If flow control or cancellation are desired, use a loop with `read_bytes(partial=True) <.read_bytes>` instead. .. versionchanged:: 4.0 ...
tornado/iostream.py
def read_until_close(self) -> Awaitable[bytes]: """Asynchronously reads all data from the socket until it is closed. This will buffer all available data until ``max_buffer_size`` is reached. If flow control or cancellation are desired, use a loop with `read_bytes(partial=True) <.read_by...
def read_until_close(self) -> Awaitable[bytes]: """Asynchronously reads all data from the socket until it is closed. This will buffer all available data until ``max_buffer_size`` is reached. If flow control or cancellation are desired, use a loop with `read_bytes(partial=True) <.read_by...
[ "Asynchronously", "reads", "all", "data", "from", "the", "socket", "until", "it", "is", "closed", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L496-L524
[ "def", "read_until_close", "(", "self", ")", "->", "Awaitable", "[", "bytes", "]", ":", "future", "=", "self", ".", "_start_read", "(", ")", "if", "self", ".", "closed", "(", ")", ":", "self", ".", "_finish_read", "(", "self", ".", "_read_buffer_size", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseIOStream.write
Asynchronously write the given data to this stream. This method returns a `.Future` that resolves (with a result of ``None``) when the write has been completed. The ``data`` argument may be of type `bytes` or `memoryview`. .. versionchanged:: 4.0 Now returns a `.Future` if...
tornado/iostream.py
def write(self, data: Union[bytes, memoryview]) -> "Future[None]": """Asynchronously write the given data to this stream. This method returns a `.Future` that resolves (with a result of ``None``) when the write has been completed. The ``data`` argument may be of type `bytes` or `memory...
def write(self, data: Union[bytes, memoryview]) -> "Future[None]": """Asynchronously write the given data to this stream. This method returns a `.Future` that resolves (with a result of ``None``) when the write has been completed. The ``data`` argument may be of type `bytes` or `memory...
[ "Asynchronously", "write", "the", "given", "data", "to", "this", "stream", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L526-L563
[ "def", "write", "(", "self", ",", "data", ":", "Union", "[", "bytes", ",", "memoryview", "]", ")", "->", "\"Future[None]\"", ":", "self", ".", "_check_closed", "(", ")", "if", "data", ":", "if", "(", "self", ".", "max_write_buffer_size", "is", "not", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseIOStream.set_close_callback
Call the given callback when the stream is closed. This mostly is not necessary for applications that use the `.Future` interface; all outstanding ``Futures`` will resolve with a `StreamClosedError` when the stream is closed. However, it is still useful as a way to signal that the strea...
tornado/iostream.py
def set_close_callback(self, callback: Optional[Callable[[], None]]) -> None: """Call the given callback when the stream is closed. This mostly is not necessary for applications that use the `.Future` interface; all outstanding ``Futures`` will resolve with a `StreamClosedError` when th...
def set_close_callback(self, callback: Optional[Callable[[], None]]) -> None: """Call the given callback when the stream is closed. This mostly is not necessary for applications that use the `.Future` interface; all outstanding ``Futures`` will resolve with a `StreamClosedError` when th...
[ "Call", "the", "given", "callback", "when", "the", "stream", "is", "closed", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L565-L578
[ "def", "set_close_callback", "(", "self", ",", "callback", ":", "Optional", "[", "Callable", "[", "[", "]", ",", "None", "]", "]", ")", "->", "None", ":", "self", ".", "_close_callback", "=", "callback", "self", ".", "_maybe_add_error_listener", "(", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseIOStream.close
Close this stream. If ``exc_info`` is true, set the ``error`` attribute to the current exception from `sys.exc_info` (or if ``exc_info`` is a tuple, use that instead of `sys.exc_info`).
tornado/iostream.py
def close( self, exc_info: Union[ None, bool, BaseException, Tuple[ "Optional[Type[BaseException]]", Optional[BaseException], Optional[TracebackType], ], ] = False, ) -> None: ...
def close( self, exc_info: Union[ None, bool, BaseException, Tuple[ "Optional[Type[BaseException]]", Optional[BaseException], Optional[TracebackType], ], ] = False, ) -> None: ...
[ "Close", "this", "stream", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L580-L617
[ "def", "close", "(", "self", ",", "exc_info", ":", "Union", "[", "None", ",", "bool", ",", "BaseException", ",", "Tuple", "[", "\"Optional[Type[BaseException]]\"", ",", "Optional", "[", "BaseException", "]", ",", "Optional", "[", "TracebackType", "]", ",", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseIOStream._try_inline_read
Attempt to complete the current read operation from buffered data. If the read can be completed without blocking, schedules the read callback on the next IOLoop iteration; otherwise starts listening for reads on the socket.
tornado/iostream.py
def _try_inline_read(self) -> None: """Attempt to complete the current read operation from buffered data. If the read can be completed without blocking, schedules the read callback on the next IOLoop iteration; otherwise starts listening for reads on the socket. """ # Se...
def _try_inline_read(self) -> None: """Attempt to complete the current read operation from buffered data. If the read can be completed without blocking, schedules the read callback on the next IOLoop iteration; otherwise starts listening for reads on the socket. """ # Se...
[ "Attempt", "to", "complete", "the", "current", "read", "operation", "from", "buffered", "data", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L817-L837
[ "def", "_try_inline_read", "(", "self", ")", "->", "None", ":", "# See if we've already got the data from a previous read", "pos", "=", "self", ".", "_find_read_pos", "(", ")", "if", "pos", "is", "not", "None", ":", "self", ".", "_read_from_buffer", "(", "pos", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseIOStream._read_to_buffer
Reads from the socket and appends the result to the read buffer. Returns the number of bytes read. Returns 0 if there is nothing to read (i.e. the read returns EWOULDBLOCK or equivalent). On error closes the socket and raises an exception.
tornado/iostream.py
def _read_to_buffer(self) -> Optional[int]: """Reads from the socket and appends the result to the read buffer. Returns the number of bytes read. Returns 0 if there is nothing to read (i.e. the read returns EWOULDBLOCK or equivalent). On error closes the socket and raises an exception...
def _read_to_buffer(self) -> Optional[int]: """Reads from the socket and appends the result to the read buffer. Returns the number of bytes read. Returns 0 if there is nothing to read (i.e. the read returns EWOULDBLOCK or equivalent). On error closes the socket and raises an exception...
[ "Reads", "from", "the", "socket", "and", "appends", "the", "result", "to", "the", "read", "buffer", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L839-L885
[ "def", "_read_to_buffer", "(", "self", ")", "->", "Optional", "[", "int", "]", ":", "try", ":", "while", "True", ":", "try", ":", "if", "self", ".", "_user_read_buffer", ":", "buf", "=", "memoryview", "(", "self", ".", "_read_buffer", ")", "[", "self",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseIOStream._read_from_buffer
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.
tornado/iostream.py
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: """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 ...
[ "Attempts", "to", "complete", "the", "currently", "-", "pending", "read", "from", "the", "buffer", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L887-L895
[ "def", "_read_from_buffer", "(", "self", ",", "pos", ":", "int", ")", "->", "None", ":", "self", ".", "_read_bytes", "=", "self", ".", "_read_delimiter", "=", "self", ".", "_read_regex", "=", "None", "self", ".", "_read_partial", "=", "False", "self", "....
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseIOStream._find_read_pos
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.
tornado/iostream.py
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]: """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 ( ...
[ "Attempts", "to", "find", "a", "position", "in", "the", "read", "buffer", "that", "satisfies", "the", "currently", "-", "pending", "read", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L897-L937
[ "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...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseIOStream._add_io_state
Adds `state` (IOLoop.{READ,WRITE} flags) to our event handler. Implementation notes: Reads and writes have a fast path and a slow path. The fast path reads synchronously from socket buffers, while the slow path uses `_add_io_state` to schedule an IOLoop callback. To detect clo...
tornado/iostream.py
def _add_io_state(self, state: int) -> None: """Adds `state` (IOLoop.{READ,WRITE} flags) to our event handler. Implementation notes: Reads and writes have a fast path and a slow path. The fast path reads synchronously from socket buffers, while the slow path uses `_add_io_state` to sch...
def _add_io_state(self, state: int) -> None: """Adds `state` (IOLoop.{READ,WRITE} flags) to our event handler. Implementation notes: Reads and writes have a fast path and a slow path. The fast path reads synchronously from socket buffers, while the slow path uses `_add_io_state` to sch...
[ "Adds", "state", "(", "IOLoop", ".", "{", "READ", "WRITE", "}", "flags", ")", "to", "our", "event", "handler", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1025-L1052
[ "def", "_add_io_state", "(", "self", ",", "state", ":", "int", ")", "->", "None", ":", "if", "self", ".", "closed", "(", ")", ":", "# connection has been closed, so there can be no future events", "return", "if", "self", ".", "_state", "is", "None", ":", "self...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseIOStream._is_connreset
Return ``True`` if exc is ECONNRESET or equivalent. May be overridden in subclasses.
tornado/iostream.py
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 ``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 )
[ "Return", "True", "if", "exc", "is", "ECONNRESET", "or", "equivalent", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1054-L1062
[ "def", "_is_connreset", "(", "self", ",", "exc", ":", "BaseException", ")", "->", "bool", ":", "return", "(", "isinstance", "(", "exc", ",", "(", "socket", ".", "error", ",", "IOError", ")", ")", "and", "errno_from_exception", "(", "exc", ")", "in", "_...
b8b481770bcdb333a69afde5cce7eaa449128326
train
IOStream.connect
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...
tornado/iostream.py
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]": """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...
[ "Connects", "the", "socket", "to", "a", "remote", "address", "without", "blocking", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1148-L1219
[ "def", "connect", "(", "self", ":", "_IOStreamType", ",", "address", ":", "tuple", ",", "server_hostname", ":", "str", "=", "None", ")", "->", "\"Future[_IOStreamType]\"", ":", "self", ".", "_connecting", "=", "True", "future", "=", "Future", "(", ")", "# ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
IOStream.start_tls
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...
tornado/iostream.py
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, ) -> Awaitable["SSLIOStream"]: """Convert this `IOStream` to an `SSLIOStream`. This enables protocols that begin in clear-text mode and ...
[ "Convert", "this", "IOStream", "to", "an", "SSLIOStream", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1221-L1295
[ "def", "start_tls", "(", "self", ",", "server_side", ":", "bool", ",", "ssl_options", ":", "Union", "[", "Dict", "[", "str", ",", "Any", "]", ",", "ssl", ".", "SSLContext", "]", "=", "None", ",", "server_hostname", ":", "str", "=", "None", ",", ")", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
SSLIOStream._verify_cert
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.
tornado/iostream.py
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: """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", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1442-L1467
[ "def", "_verify_cert", "(", "self", ",", "peercert", ":", "Any", ")", "->", "bool", ":", "if", "isinstance", "(", "self", ".", "_ssl_options", ",", "dict", ")", ":", "verify_mode", "=", "self", ".", "_ssl_options", ".", "get", "(", "\"cert_reqs\"", ",", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
SSLIOStream.wait_for_handshake
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 ...
tornado/iostream.py
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]": """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...
[ "Wait", "for", "the", "initial", "SSL", "handshake", "to", "complete", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1527-L1557
[ "def", "wait_for_handshake", "(", "self", ")", "->", "\"Future[SSLIOStream]\"", ":", "if", "self", ".", "_ssl_connect_future", "is", "not", "None", ":", "raise", "RuntimeError", "(", "\"Already waiting\"", ")", "future", "=", "self", ".", "_ssl_connect_future", "=...
b8b481770bcdb333a69afde5cce7eaa449128326
train
enable_pretty_logging
Turns on formatted logging output as configured. This is called automatically by `tornado.options.parse_command_line` and `tornado.options.parse_config_file`.
tornado/log.py
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: """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...
[ "Turns", "on", "formatted", "logging", "output", "as", "configured", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/log.py#L211-L256
[ "def", "enable_pretty_logging", "(", "options", ":", "Any", "=", "None", ",", "logger", ":", "logging", ".", "Logger", "=", "None", ")", "->", "None", ":", "if", "options", "is", "None", ":", "import", "tornado", ".", "options", "options", "=", "tornado"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
define_logging_options
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.
tornado/log.py
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: """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...
[ "Add", "logging", "-", "related", "flags", "to", "options", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/log.py#L259-L337
[ "def", "define_logging_options", "(", "options", ":", "Any", "=", "None", ")", "->", "None", ":", "if", "options", "is", "None", ":", "# late import to prevent cycle", "import", "tornado", ".", "options", "options", "=", "tornado", ".", "options", ".", "option...
b8b481770bcdb333a69afde5cce7eaa449128326
train
SimpleAsyncHTTPClient.initialize
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`` ...
tornado/simple_httpclient.py
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: Resolver = None, defaults: Dict[str, Any] = None, max_header_size: int = None, max_body_size: int = None, ...
[ "Creates", "a", "AsyncHTTPClient", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/simple_httpclient.py#L89-L157
[ "def", "initialize", "(", "# type: ignore", "self", ",", "max_clients", ":", "int", "=", "10", ",", "hostname_mapping", ":", "Dict", "[", "str", ",", "str", "]", "=", "None", ",", "max_buffer_size", ":", "int", "=", "104857600", ",", "resolver", ":", "Re...
b8b481770bcdb333a69afde5cce7eaa449128326
train
SimpleAsyncHTTPClient._on_timeout
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.
tornado/simple_httpclient.py
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: """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, ...
[ "Timeout", "callback", "of", "request", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/simple_httpclient.py#L229-L248
[ "def", "_on_timeout", "(", "self", ",", "key", ":", "object", ",", "info", ":", "str", "=", "None", ")", "->", "None", ":", "request", ",", "callback", ",", "timeout_handle", "=", "self", ".", "waiting", "[", "key", "]", "self", ".", "queue", ".", ...
b8b481770bcdb333a69afde5cce7eaa449128326