repo
stringclasses
85 values
path
stringlengths
8
121
func_name
stringlengths
1
82
original_string
stringlengths
112
65.5k
language
stringclasses
1 value
code
stringlengths
112
65.5k
code_tokens
listlengths
20
4.09k
docstring
stringlengths
3
46.3k
docstring_tokens
listlengths
1
564
sha
stringclasses
85 values
url
stringlengths
93
218
partition
stringclasses
1 value
tornadoweb/tornado
tornado/iostream.py
_StreamBuffer.peek
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"") ...
python
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", ":", "assert", "size", ">", "0", "try", ":", "is_memview", ",", "b", "=", "self", ".", "_buffers", "[", "0", "]", "except", "IndexError", ":", "return", "memoryview", "(", ...
Get a view over at most ``size`` bytes (possibly fewer) at the current buffer position.
[ "Get", "a", "view", "over", "at", "most", "size", "bytes", "(", "possibly", "fewer", ")", "at", "the", "current", "buffer", "position", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L181-L196
train
tornadoweb/tornado
tornado/iostream.py
_StreamBuffer.advance
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...
python
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", ":", "assert", "0", "<", "size", "<=", "self", ".", "_size", "self", ".", "_size", "-=", "size", "pos", "=", "self", ".", "_first_pos", "buffers", "=", "self", ".", "_buffer...
Advance the current buffer position by ``size`` bytes.
[ "Advance", "the", "current", "buffer", "position", "by", "size", "bytes", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L198-L226
train
tornadoweb/tornado
tornado/iostream.py
BaseIOStream.read_until_regex
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 ...
python
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", "]", ":", "future", "=", "self", ".", "_start_read", "(", ")", "self", ".", "_read_regex", "=", "re", ...
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...
[ "Asynchronously", "read", "until", "we", "have", "matched", "the", "given", "regex", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L349-L384
train
tornadoweb/tornado
tornado/iostream.py
BaseIOStream.read_until
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...
python
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", "]", ":", "future", "=", "self", ".", "_start_read", "(", ")", "self", ".", "_read_delimiter", "=", "deli...
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...
[ "Asynchronously", "read", "until", "we", "have", "found", "the", "given", "delimiter", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L386-L417
train
tornadoweb/tornado
tornado/iostream.py
BaseIOStream.read_bytes
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 `...
python
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", "]", ":", "future", "=", "self", ".", "_start_read", "(", ")", "assert", "isinstance", "(", "num_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...
[ "Asynchronously", "read", "a", "number", "of", "bytes", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L419-L445
train
tornadoweb/tornado
tornado/iostream.py
BaseIOStream.read_into
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...
python
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", "]", ":", "future", "=", "self", ".", "_start_read", "(", ")", "# First copy data already in read buffer", "availabl...
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...
[ "Asynchronously", "read", "a", "number", "of", "bytes", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L447-L494
train
tornadoweb/tornado
tornado/iostream.py
BaseIOStream.read_until_close
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...
python
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", "]", ":", "future", "=", "self", ".", "_start_read", "(", ")", "if", "self", ".", "closed", "(", ")", ":", "self", ".", "_finish_read", "(", "self", ".", "_read_buffer_size", ...
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 ...
[ "Asynchronously", "reads", "all", "data", "from", "the", "socket", "until", "it", "is", "closed", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L496-L524
train
tornadoweb/tornado
tornado/iostream.py
BaseIOStream.write
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...
python
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]\"", ":", "self", ".", "_check_closed", "(", ")", "if", "data", ":", "if", "(", "self", ".", "max_write_buffer_size", "is", "not", "...
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...
[ "Asynchronously", "write", "the", "given", "data", "to", "this", "stream", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L526-L563
train
tornadoweb/tornado
tornado/iostream.py
BaseIOStream.set_close_callback
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...
python
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", ":", "self", ".", "_close_callback", "=", "callback", "self", ".", "_maybe_add_error_listener", "(", ")" ]
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...
[ "Call", "the", "given", "callback", "when", "the", "stream", "is", "closed", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L565-L578
train
tornadoweb/tornado
tornado/iostream.py
BaseIOStream.close
def close( self, exc_info: Union[ None, bool, BaseException, Tuple[ "Optional[Type[BaseException]]", Optional[BaseException], Optional[TracebackType], ], ] = False, ) -> None: ...
python
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", "]", ",", "...
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`).
[ "Close", "this", "stream", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L580-L617
train
tornadoweb/tornado
tornado/iostream.py
BaseIOStream._try_inline_read
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...
python
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", ":", "# 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", ...
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.
[ "Attempt", "to", "complete", "the", "current", "read", "operation", "from", "buffered", "data", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L817-L837
train
tornadoweb/tornado
tornado/iostream.py
BaseIOStream._read_to_buffer
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...
python
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", "]", ":", "try", ":", "while", "True", ":", "try", ":", "if", "self", ".", "_user_read_buffer", ":", "buf", "=", "memoryview", "(", "self", ".", "_read_buffer", ")", "[", "self",...
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", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L839-L885
train
tornadoweb/tornado
tornado/iostream.py
BaseIOStream._read_from_buffer
def _read_from_buffer(self, pos: int) -> None: """Attempts to complete the currently-pending read from the buffer. The argument is either a position in the read buffer or None, as returned by _find_read_pos. """ self._read_bytes = self._read_delimiter = self._read_regex = None ...
python
def _read_from_buffer(self, pos: int) -> None: """Attempts to complete the currently-pending read from the buffer. The argument is either a position in the read buffer or None, as returned by _find_read_pos. """ self._read_bytes = self._read_delimiter = self._read_regex = None ...
[ "def", "_read_from_buffer", "(", "self", ",", "pos", ":", "int", ")", "->", "None", ":", "self", ".", "_read_bytes", "=", "self", ".", "_read_delimiter", "=", "self", ".", "_read_regex", "=", "None", "self", ".", "_read_partial", "=", "False", "self", "....
Attempts to complete the currently-pending read from the buffer. The argument is either a position in the read buffer or None, as returned by _find_read_pos.
[ "Attempts", "to", "complete", "the", "currently", "-", "pending", "read", "from", "the", "buffer", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L887-L895
train
tornadoweb/tornado
tornado/iostream.py
BaseIOStream._find_read_pos
def _find_read_pos(self) -> Optional[int]: """Attempts to find a position in the read buffer that satisfies the currently-pending read. Returns a position in the buffer if the current read can be satisfied, or None if it cannot. """ if self._read_bytes is not None and ( ...
python
def _find_read_pos(self) -> Optional[int]: """Attempts to find a position in the read buffer that satisfies the currently-pending read. Returns a position in the buffer if the current read can be satisfied, or None if it cannot. """ if self._read_bytes is not None and ( ...
[ "def", "_find_read_pos", "(", "self", ")", "->", "Optional", "[", "int", "]", ":", "if", "self", ".", "_read_bytes", "is", "not", "None", "and", "(", "self", ".", "_read_buffer_size", ">=", "self", ".", "_read_bytes", "or", "(", "self", ".", "_read_parti...
Attempts to find a position in the read buffer that satisfies the currently-pending read. Returns a position in the buffer if the current read can be satisfied, or None if it cannot.
[ "Attempts", "to", "find", "a", "position", "in", "the", "read", "buffer", "that", "satisfies", "the", "currently", "-", "pending", "read", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L897-L937
train
tornadoweb/tornado
tornado/iostream.py
BaseIOStream._add_io_state
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...
python
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", ":", "if", "self", ".", "closed", "(", ")", ":", "# connection has been closed, so there can be no future events", "return", "if", "self", ".", "_state", "is", "None", ":", "self...
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...
[ "Adds", "state", "(", "IOLoop", ".", "{", "READ", "WRITE", "}", "flags", ")", "to", "our", "event", "handler", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1025-L1052
train
tornadoweb/tornado
tornado/iostream.py
BaseIOStream._is_connreset
def _is_connreset(self, exc: BaseException) -> bool: """Return ``True`` if exc is ECONNRESET or equivalent. May be overridden in subclasses. """ return ( isinstance(exc, (socket.error, IOError)) and errno_from_exception(exc) in _ERRNO_CONNRESET )
python
def _is_connreset(self, exc: BaseException) -> bool: """Return ``True`` if exc is ECONNRESET or equivalent. May be overridden in subclasses. """ return ( isinstance(exc, (socket.error, IOError)) and errno_from_exception(exc) in _ERRNO_CONNRESET )
[ "def", "_is_connreset", "(", "self", ",", "exc", ":", "BaseException", ")", "->", "bool", ":", "return", "(", "isinstance", "(", "exc", ",", "(", "socket", ".", "error", ",", "IOError", ")", ")", "and", "errno_from_exception", "(", "exc", ")", "in", "_...
Return ``True`` if exc is ECONNRESET or equivalent. May be overridden in subclasses.
[ "Return", "True", "if", "exc", "is", "ECONNRESET", "or", "equivalent", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1054-L1062
train
tornadoweb/tornado
tornado/iostream.py
IOStream.connect
def connect( self: _IOStreamType, address: tuple, server_hostname: str = None ) -> "Future[_IOStreamType]": """Connects the socket to a remote address without blocking. May only be called if the socket passed to the constructor was not previously connected. The address parameter is...
python
def connect( self: _IOStreamType, address: tuple, server_hostname: str = None ) -> "Future[_IOStreamType]": """Connects the socket to a remote address without blocking. May only be called if the socket passed to the constructor was not previously connected. The address parameter is...
[ "def", "connect", "(", "self", ":", "_IOStreamType", ",", "address", ":", "tuple", ",", "server_hostname", ":", "str", "=", "None", ")", "->", "\"Future[_IOStreamType]\"", ":", "self", ".", "_connecting", "=", "True", "future", "=", "Future", "(", ")", "# ...
Connects the socket to a remote address without blocking. May only be called if the socket passed to the constructor was not previously connected. The address parameter is in the same format as for `socket.connect <socket.socket.connect>` for the type of socket passed to the IOStream c...
[ "Connects", "the", "socket", "to", "a", "remote", "address", "without", "blocking", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1148-L1219
train
tornadoweb/tornado
tornado/iostream.py
IOStream.start_tls
def start_tls( self, server_side: bool, ssl_options: Union[Dict[str, Any], ssl.SSLContext] = None, server_hostname: str = None, ) -> Awaitable["SSLIOStream"]: """Convert this `IOStream` to an `SSLIOStream`. This enables protocols that begin in clear-text mode and ...
python
def start_tls( self, server_side: bool, ssl_options: Union[Dict[str, Any], ssl.SSLContext] = None, server_hostname: str = None, ) -> Awaitable["SSLIOStream"]: """Convert this `IOStream` to an `SSLIOStream`. This enables protocols that begin in clear-text mode and ...
[ "def", "start_tls", "(", "self", ",", "server_side", ":", "bool", ",", "ssl_options", ":", "Union", "[", "Dict", "[", "str", ",", "Any", "]", ",", "ssl", ".", "SSLContext", "]", "=", "None", ",", "server_hostname", ":", "str", "=", "None", ",", ")", ...
Convert this `IOStream` to an `SSLIOStream`. This enables protocols that begin in clear-text mode and switch to SSL after some initial negotiation (such as the ``STARTTLS`` extension to SMTP and IMAP). This method cannot be used if there are outstanding reads or writes on the s...
[ "Convert", "this", "IOStream", "to", "an", "SSLIOStream", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1221-L1295
train
tornadoweb/tornado
tornado/iostream.py
SSLIOStream._verify_cert
def _verify_cert(self, peercert: Any) -> bool: """Returns ``True`` if peercert is valid according to the configured validation mode and hostname. The ssl handshake already tested the certificate for a valid CA signature; the only thing that remains is to check the hostname. ...
python
def _verify_cert(self, peercert: Any) -> bool: """Returns ``True`` if peercert is valid according to the configured validation mode and hostname. The ssl handshake already tested the certificate for a valid CA signature; the only thing that remains is to check the hostname. ...
[ "def", "_verify_cert", "(", "self", ",", "peercert", ":", "Any", ")", "->", "bool", ":", "if", "isinstance", "(", "self", ".", "_ssl_options", ",", "dict", ")", ":", "verify_mode", "=", "self", ".", "_ssl_options", ".", "get", "(", "\"cert_reqs\"", ",", ...
Returns ``True`` if peercert is valid according to the configured validation mode and hostname. The ssl handshake already tested the certificate for a valid CA signature; the only thing that remains is to check the hostname.
[ "Returns", "True", "if", "peercert", "is", "valid", "according", "to", "the", "configured", "validation", "mode", "and", "hostname", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1442-L1467
train
tornadoweb/tornado
tornado/iostream.py
SSLIOStream.wait_for_handshake
def wait_for_handshake(self) -> "Future[SSLIOStream]": """Wait for the initial SSL handshake to complete. If a ``callback`` is given, it will be called with no arguments once the handshake is complete; otherwise this method returns a `.Future` which will resolve to the stream it...
python
def wait_for_handshake(self) -> "Future[SSLIOStream]": """Wait for the initial SSL handshake to complete. If a ``callback`` is given, it will be called with no arguments once the handshake is complete; otherwise this method returns a `.Future` which will resolve to the stream it...
[ "def", "wait_for_handshake", "(", "self", ")", "->", "\"Future[SSLIOStream]\"", ":", "if", "self", ".", "_ssl_connect_future", "is", "not", "None", ":", "raise", "RuntimeError", "(", "\"Already waiting\"", ")", "future", "=", "self", ".", "_ssl_connect_future", "=...
Wait for the initial SSL handshake to complete. If a ``callback`` is given, it will be called with no arguments once the handshake is complete; otherwise this method returns a `.Future` which will resolve to the stream itself after the handshake is complete. Once the handshake ...
[ "Wait", "for", "the", "initial", "SSL", "handshake", "to", "complete", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/iostream.py#L1527-L1557
train
tornadoweb/tornado
tornado/log.py
enable_pretty_logging
def enable_pretty_logging(options: Any = None, logger: logging.Logger = None) -> None: """Turns on formatted logging output as configured. This is called automatically by `tornado.options.parse_command_line` and `tornado.options.parse_config_file`. """ if options is None: import tornado.opt...
python
def enable_pretty_logging(options: Any = None, logger: logging.Logger = None) -> None: """Turns on formatted logging output as configured. This is called automatically by `tornado.options.parse_command_line` and `tornado.options.parse_config_file`. """ if options is None: import tornado.opt...
[ "def", "enable_pretty_logging", "(", "options", ":", "Any", "=", "None", ",", "logger", ":", "logging", ".", "Logger", "=", "None", ")", "->", "None", ":", "if", "options", "is", "None", ":", "import", "tornado", ".", "options", "options", "=", "tornado"...
Turns on formatted logging output as configured. This is called automatically by `tornado.options.parse_command_line` and `tornado.options.parse_config_file`.
[ "Turns", "on", "formatted", "logging", "output", "as", "configured", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/log.py#L211-L256
train
tornadoweb/tornado
tornado/log.py
define_logging_options
def define_logging_options(options: Any = None) -> None: """Add logging-related flags to ``options``. These options are present automatically on the default options instance; this method is only necessary if you have created your own `.OptionParser`. .. versionadded:: 4.2 This function existed...
python
def define_logging_options(options: Any = None) -> None: """Add logging-related flags to ``options``. These options are present automatically on the default options instance; this method is only necessary if you have created your own `.OptionParser`. .. versionadded:: 4.2 This function existed...
[ "def", "define_logging_options", "(", "options", ":", "Any", "=", "None", ")", "->", "None", ":", "if", "options", "is", "None", ":", "# late import to prevent cycle", "import", "tornado", ".", "options", "options", "=", "tornado", ".", "options", ".", "option...
Add logging-related flags to ``options``. These options are present automatically on the default options instance; this method is only necessary if you have created your own `.OptionParser`. .. versionadded:: 4.2 This function existed in prior versions but was broken and undocumented until 4.2.
[ "Add", "logging", "-", "related", "flags", "to", "options", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/log.py#L259-L337
train
tornadoweb/tornado
tornado/simple_httpclient.py
SimpleAsyncHTTPClient.initialize
def initialize( # type: ignore self, max_clients: int = 10, hostname_mapping: Dict[str, str] = None, max_buffer_size: int = 104857600, resolver: Resolver = None, defaults: Dict[str, Any] = None, max_header_size: int = None, max_body_size: int = None, ...
python
def initialize( # type: ignore self, max_clients: int = 10, hostname_mapping: Dict[str, str] = None, max_buffer_size: int = 104857600, resolver: Resolver = None, defaults: Dict[str, Any] = None, max_header_size: int = None, max_body_size: int = None, ...
[ "def", "initialize", "(", "# type: ignore", "self", ",", "max_clients", ":", "int", "=", "10", ",", "hostname_mapping", ":", "Dict", "[", "str", ",", "str", "]", "=", "None", ",", "max_buffer_size", ":", "int", "=", "104857600", ",", "resolver", ":", "Re...
Creates a AsyncHTTPClient. Only a single AsyncHTTPClient instance exists per IOLoop in order to provide limitations on the number of pending connections. ``force_instance=True`` may be used to suppress this behavior. Note that because of this implicit reuse, unless ``force_instance`` ...
[ "Creates", "a", "AsyncHTTPClient", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/simple_httpclient.py#L89-L157
train
tornadoweb/tornado
tornado/simple_httpclient.py
SimpleAsyncHTTPClient._on_timeout
def _on_timeout(self, key: object, info: str = None) -> None: """Timeout callback of request. Construct a timeout HTTPResponse when a timeout occurs. :arg object key: A simple object to mark the request. :info string key: More detailed timeout information. """ request, ...
python
def _on_timeout(self, key: object, info: str = None) -> None: """Timeout callback of request. Construct a timeout HTTPResponse when a timeout occurs. :arg object key: A simple object to mark the request. :info string key: More detailed timeout information. """ request, ...
[ "def", "_on_timeout", "(", "self", ",", "key", ":", "object", ",", "info", ":", "str", "=", "None", ")", "->", "None", ":", "request", ",", "callback", ",", "timeout_handle", "=", "self", ".", "waiting", "[", "key", "]", "self", ".", "queue", ".", ...
Timeout callback of request. Construct a timeout HTTPResponse when a timeout occurs. :arg object key: A simple object to mark the request. :info string key: More detailed timeout information.
[ "Timeout", "callback", "of", "request", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/simple_httpclient.py#L229-L248
train
tornadoweb/tornado
tornado/simple_httpclient.py
_HTTPConnection._on_timeout
def _on_timeout(self, info: str = None) -> None: """Timeout callback of _HTTPConnection instance. Raise a `HTTPTimeoutError` when a timeout occurs. :info string key: More detailed timeout information. """ self._timeout = None error_message = "Timeout {0}".format(info) i...
python
def _on_timeout(self, info: str = None) -> None: """Timeout callback of _HTTPConnection instance. Raise a `HTTPTimeoutError` when a timeout occurs. :info string key: More detailed timeout information. """ self._timeout = None error_message = "Timeout {0}".format(info) i...
[ "def", "_on_timeout", "(", "self", ",", "info", ":", "str", "=", "None", ")", "->", "None", ":", "self", ".", "_timeout", "=", "None", "error_message", "=", "\"Timeout {0}\"", ".", "format", "(", "info", ")", "if", "info", "else", "\"Timeout\"", "if", ...
Timeout callback of _HTTPConnection instance. Raise a `HTTPTimeoutError` when a timeout occurs. :info string key: More detailed timeout information.
[ "Timeout", "callback", "of", "_HTTPConnection", "instance", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/simple_httpclient.py#L474-L486
train
tornadoweb/tornado
tornado/auth.py
_oauth10a_signature
def _oauth10a_signature( consumer_token: Dict[str, Any], method: str, url: str, parameters: Dict[str, Any] = {}, token: Dict[str, Any] = None, ) -> bytes: """Calculates the HMAC-SHA1 OAuth 1.0a signature for the given request. See http://oauth.net/core/1.0a/#signing_process """ part...
python
def _oauth10a_signature( consumer_token: Dict[str, Any], method: str, url: str, parameters: Dict[str, Any] = {}, token: Dict[str, Any] = None, ) -> bytes: """Calculates the HMAC-SHA1 OAuth 1.0a signature for the given request. See http://oauth.net/core/1.0a/#signing_process """ part...
[ "def", "_oauth10a_signature", "(", "consumer_token", ":", "Dict", "[", "str", ",", "Any", "]", ",", "method", ":", "str", ",", "url", ":", "str", ",", "parameters", ":", "Dict", "[", "str", ",", "Any", "]", "=", "{", "}", ",", "token", ":", "Dict",...
Calculates the HMAC-SHA1 OAuth 1.0a signature for the given request. See http://oauth.net/core/1.0a/#signing_process
[ "Calculates", "the", "HMAC", "-", "SHA1", "OAuth", "1", ".", "0a", "signature", "for", "the", "given", "request", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L1130-L1162
train
tornadoweb/tornado
tornado/auth.py
OpenIdMixin.authenticate_redirect
def authenticate_redirect( self, callback_uri: str = None, ax_attrs: List[str] = ["name", "email", "language", "username"], ) -> None: """Redirects to the authentication URL for this service. After authentication, the service will redirect back to the given callback ...
python
def authenticate_redirect( self, callback_uri: str = None, ax_attrs: List[str] = ["name", "email", "language", "username"], ) -> None: """Redirects to the authentication URL for this service. After authentication, the service will redirect back to the given callback ...
[ "def", "authenticate_redirect", "(", "self", ",", "callback_uri", ":", "str", "=", "None", ",", "ax_attrs", ":", "List", "[", "str", "]", "=", "[", "\"name\"", ",", "\"email\"", ",", "\"language\"", ",", "\"username\"", "]", ",", ")", "->", "None", ":", ...
Redirects to the authentication URL for this service. After authentication, the service will redirect back to the given callback URI with additional parameters including ``openid.mode``. We request the given attributes for the authenticated user by default (name, email, language, and u...
[ "Redirects", "to", "the", "authentication", "URL", "for", "this", "service", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L88-L114
train
tornadoweb/tornado
tornado/auth.py
OpenIdMixin.get_authenticated_user
async def get_authenticated_user( self, http_client: httpclient.AsyncHTTPClient = None ) -> Dict[str, Any]: """Fetches the authenticated user data upon redirect. This method should be called by the handler that receives the redirect from the `authenticate_redirect()` method (which i...
python
async def get_authenticated_user( self, http_client: httpclient.AsyncHTTPClient = None ) -> Dict[str, Any]: """Fetches the authenticated user data upon redirect. This method should be called by the handler that receives the redirect from the `authenticate_redirect()` method (which i...
[ "async", "def", "get_authenticated_user", "(", "self", ",", "http_client", ":", "httpclient", ".", "AsyncHTTPClient", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "handler", "=", "cast", "(", "RequestHandler", ",", "self", ")", "# Veri...
Fetches the authenticated user data upon redirect. This method should be called by the handler that receives the redirect from the `authenticate_redirect()` method (which is often the same as the one that calls it; in that case you would call `get_authenticated_user` if the ``openid.mod...
[ "Fetches", "the", "authenticated", "user", "data", "upon", "redirect", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L116-L146
train
tornadoweb/tornado
tornado/auth.py
OAuthMixin.authorize_redirect
async def authorize_redirect( self, callback_uri: str = None, extra_params: Dict[str, Any] = None, http_client: httpclient.AsyncHTTPClient = None, ) -> None: """Redirects the user to obtain OAuth authorization for this service. The ``callback_uri`` may be omitted if ...
python
async def authorize_redirect( self, callback_uri: str = None, extra_params: Dict[str, Any] = None, http_client: httpclient.AsyncHTTPClient = None, ) -> None: """Redirects the user to obtain OAuth authorization for this service. The ``callback_uri`` may be omitted if ...
[ "async", "def", "authorize_redirect", "(", "self", ",", "callback_uri", ":", "str", "=", "None", ",", "extra_params", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ",", "http_client", ":", "httpclient", ".", "AsyncHTTPClient", "=", "None", ",", ...
Redirects the user to obtain OAuth authorization for this service. The ``callback_uri`` may be omitted if you have previously registered a callback URI with the third-party service. For some services, you must use a previously-registered callback URI and cannot specify a callback via th...
[ "Redirects", "the", "user", "to", "obtain", "OAuth", "authorization", "for", "this", "service", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L287-L334
train
tornadoweb/tornado
tornado/auth.py
OAuthMixin.get_authenticated_user
async def get_authenticated_user( self, http_client: httpclient.AsyncHTTPClient = None ) -> Dict[str, Any]: """Gets the OAuth authorized user and access token. This method should be called from the handler for your OAuth callback URL to complete the registration process. We run the ...
python
async def get_authenticated_user( self, http_client: httpclient.AsyncHTTPClient = None ) -> Dict[str, Any]: """Gets the OAuth authorized user and access token. This method should be called from the handler for your OAuth callback URL to complete the registration process. We run the ...
[ "async", "def", "get_authenticated_user", "(", "self", ",", "http_client", ":", "httpclient", ".", "AsyncHTTPClient", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "handler", "=", "cast", "(", "RequestHandler", ",", "self", ")", "reques...
Gets the OAuth authorized user and access token. This method should be called from the handler for your OAuth callback URL to complete the registration process. We run the callback with the authenticated user dictionary. This dictionary will contain an ``access_key`` which can be used ...
[ "Gets", "the", "OAuth", "authorized", "user", "and", "access", "token", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L336-L380
train
tornadoweb/tornado
tornado/auth.py
OAuthMixin._oauth_get_user_future
async def _oauth_get_user_future( self, access_token: Dict[str, Any] ) -> Dict[str, Any]: """Subclasses must override this to get basic information about the user. Should be a coroutine whose result is a dictionary containing information about the user, which may have been ...
python
async def _oauth_get_user_future( self, access_token: Dict[str, Any] ) -> Dict[str, Any]: """Subclasses must override this to get basic information about the user. Should be a coroutine whose result is a dictionary containing information about the user, which may have been ...
[ "async", "def", "_oauth_get_user_future", "(", "self", ",", "access_token", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "raise", "NotImplementedError", "(", ")" ]
Subclasses must override this to get basic information about the user. Should be a coroutine whose result is a dictionary containing information about the user, which may have been retrieved by using ``access_token`` to make a request to the service. The access token wi...
[ "Subclasses", "must", "override", "this", "to", "get", "basic", "information", "about", "the", "user", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L468-L490
train
tornadoweb/tornado
tornado/auth.py
OAuth2Mixin.authorize_redirect
def authorize_redirect( self, redirect_uri: str = None, client_id: str = None, client_secret: str = None, extra_params: Dict[str, Any] = None, scope: str = None, response_type: str = "code", ) -> None: """Redirects the user to obtain OAuth authorizatio...
python
def authorize_redirect( self, redirect_uri: str = None, client_id: str = None, client_secret: str = None, extra_params: Dict[str, Any] = None, scope: str = None, response_type: str = "code", ) -> None: """Redirects the user to obtain OAuth authorizatio...
[ "def", "authorize_redirect", "(", "self", ",", "redirect_uri", ":", "str", "=", "None", ",", "client_id", ":", "str", "=", "None", ",", "client_secret", ":", "str", "=", "None", ",", "extra_params", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None"...
Redirects the user to obtain OAuth authorization for this service. Some providers require that you register a redirect URL with your application instead of passing one via this method. You should call this method to log the user in, and then call ``get_authenticated_user`` in the handle...
[ "Redirects", "the", "user", "to", "obtain", "OAuth", "authorization", "for", "this", "service", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L548-L581
train
tornadoweb/tornado
tornado/auth.py
OAuth2Mixin.oauth2_request
async def oauth2_request( self, url: str, access_token: str = None, post_args: Dict[str, Any] = None, **args: Any ) -> Any: """Fetches the given URL auth an OAuth2 access token. If the request is a POST, ``post_args`` should be provided. Query string ...
python
async def oauth2_request( self, url: str, access_token: str = None, post_args: Dict[str, Any] = None, **args: Any ) -> Any: """Fetches the given URL auth an OAuth2 access token. If the request is a POST, ``post_args`` should be provided. Query string ...
[ "async", "def", "oauth2_request", "(", "self", ",", "url", ":", "str", ",", "access_token", ":", "str", "=", "None", ",", "post_args", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ",", "*", "*", "args", ":", "Any", ")", "->", "Any", ":"...
Fetches the given URL auth an OAuth2 access token. If the request is a POST, ``post_args`` should be provided. Query string arguments should be given as keyword arguments. Example usage: ..testcode:: class MainHandler(tornado.web.RequestHandler, ...
[ "Fetches", "the", "given", "URL", "auth", "an", "OAuth2", "access", "token", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L605-L659
train
tornadoweb/tornado
tornado/auth.py
TwitterMixin.authenticate_redirect
async def authenticate_redirect(self, callback_uri: str = None) -> None: """Just like `~OAuthMixin.authorize_redirect`, but auto-redirects if authorized. This is generally the right interface to use if you are using Twitter for single-sign on. .. versionchanged:: 3.1 ...
python
async def authenticate_redirect(self, callback_uri: str = None) -> None: """Just like `~OAuthMixin.authorize_redirect`, but auto-redirects if authorized. This is generally the right interface to use if you are using Twitter for single-sign on. .. versionchanged:: 3.1 ...
[ "async", "def", "authenticate_redirect", "(", "self", ",", "callback_uri", ":", "str", "=", "None", ")", "->", "None", ":", "http", "=", "self", ".", "get_auth_http_client", "(", ")", "response", "=", "await", "http", ".", "fetch", "(", "self", ".", "_oa...
Just like `~OAuthMixin.authorize_redirect`, but auto-redirects if authorized. This is generally the right interface to use if you are using Twitter for single-sign on. .. versionchanged:: 3.1 Now returns a `.Future` and takes an optional callback, for compatibilit...
[ "Just", "like", "~OAuthMixin", ".", "authorize_redirect", "but", "auto", "-", "redirects", "if", "authorized", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L712-L732
train
tornadoweb/tornado
tornado/auth.py
TwitterMixin.twitter_request
async def twitter_request( self, path: str, access_token: Dict[str, Any], post_args: Dict[str, Any] = None, **args: Any ) -> Any: """Fetches the given API path, e.g., ``statuses/user_timeline/btaylor`` The path should not include the format or API version num...
python
async def twitter_request( self, path: str, access_token: Dict[str, Any], post_args: Dict[str, Any] = None, **args: Any ) -> Any: """Fetches the given API path, e.g., ``statuses/user_timeline/btaylor`` The path should not include the format or API version num...
[ "async", "def", "twitter_request", "(", "self", ",", "path", ":", "str", ",", "access_token", ":", "Dict", "[", "str", ",", "Any", "]", ",", "post_args", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ",", "*", "*", "args", ":", "Any", ")...
Fetches the given API path, e.g., ``statuses/user_timeline/btaylor`` The path should not include the format or API version number. (we automatically use JSON format and API version 1). If the request is a POST, ``post_args`` should be provided. Query string arguments should be given as...
[ "Fetches", "the", "given", "API", "path", "e", ".", "g", ".", "statuses", "/", "user_timeline", "/", "btaylor" ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L734-L807
train
tornadoweb/tornado
tornado/auth.py
GoogleOAuth2Mixin.get_authenticated_user
async def get_authenticated_user( self, redirect_uri: str, code: str ) -> Dict[str, Any]: """Handles the login for the Google user, returning an access token. The result is a dictionary containing an ``access_token`` field ([among others](https://developers.google.com/identity/proto...
python
async def get_authenticated_user( self, redirect_uri: str, code: str ) -> Dict[str, Any]: """Handles the login for the Google user, returning an access token. The result is a dictionary containing an ``access_token`` field ([among others](https://developers.google.com/identity/proto...
[ "async", "def", "get_authenticated_user", "(", "self", ",", "redirect_uri", ":", "str", ",", "code", ":", "str", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "# noqa: E501", "handler", "=", "cast", "(", "RequestHandler", ",", "self", ")", "http",...
Handles the login for the Google user, returning an access token. The result is a dictionary containing an ``access_token`` field ([among others](https://developers.google.com/identity/protocols/OAuth2WebServer#handlingtheresponse)). Unlike other ``get_authenticated_user`` methods in this packa...
[ "Handles", "the", "login", "for", "the", "Google", "user", "returning", "an", "access", "token", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L854-L916
train
tornadoweb/tornado
tornado/auth.py
FacebookGraphMixin.get_authenticated_user
async def get_authenticated_user( self, redirect_uri: str, client_id: str, client_secret: str, code: str, extra_fields: Dict[str, Any] = None, ) -> Optional[Dict[str, Any]]: """Handles the login for the Facebook user, returning a user object. Example ...
python
async def get_authenticated_user( self, redirect_uri: str, client_id: str, client_secret: str, code: str, extra_fields: Dict[str, Any] = None, ) -> Optional[Dict[str, Any]]: """Handles the login for the Facebook user, returning a user object. Example ...
[ "async", "def", "get_authenticated_user", "(", "self", ",", "redirect_uri", ":", "str", ",", "client_id", ":", "str", ",", "client_secret", ":", "str", ",", "code", ":", "str", ",", "extra_fields", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ...
Handles the login for the Facebook user, returning a user object. Example usage: .. testcode:: class FacebookGraphLoginHandler(tornado.web.RequestHandler, tornado.auth.FacebookGraphMixin): async def get(self): if ...
[ "Handles", "the", "login", "for", "the", "Facebook", "user", "returning", "a", "user", "object", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L927-L1032
train
tornadoweb/tornado
tornado/auth.py
FacebookGraphMixin.facebook_request
async def facebook_request( self, path: str, access_token: str = None, post_args: Dict[str, Any] = None, **args: Any ) -> Any: """Fetches the given relative API path, e.g., "/btaylor/picture" If the request is a POST, ``post_args`` should be provided. Query ...
python
async def facebook_request( self, path: str, access_token: str = None, post_args: Dict[str, Any] = None, **args: Any ) -> Any: """Fetches the given relative API path, e.g., "/btaylor/picture" If the request is a POST, ``post_args`` should be provided. Query ...
[ "async", "def", "facebook_request", "(", "self", ",", "path", ":", "str", ",", "access_token", ":", "str", "=", "None", ",", "post_args", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ",", "*", "*", "args", ":", "Any", ")", "->", "Any", ...
Fetches the given relative API path, e.g., "/btaylor/picture" If the request is a POST, ``post_args`` should be provided. Query string arguments should be given as keyword arguments. An introduction to the Facebook Graph API can be found at http://developers.facebook.com/docs/api ...
[ "Fetches", "the", "given", "relative", "API", "path", "e", ".", "g", ".", "/", "btaylor", "/", "picture" ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L1034-L1094
train
tornadoweb/tornado
tornado/locks.py
Condition.wait
def wait(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[bool]: """Wait for `.notify`. Returns a `.Future` that resolves ``True`` if the condition is notified, or ``False`` after a timeout. """ waiter = Future() # type: Future[bool] self._waiters.ap...
python
def wait(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[bool]: """Wait for `.notify`. Returns a `.Future` that resolves ``True`` if the condition is notified, or ``False`` after a timeout. """ waiter = Future() # type: Future[bool] self._waiters.ap...
[ "def", "wait", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "bool", "]", ":", "waiter", "=", "Future", "(", ")", "# type: Future[bool]", "self", ".", "_waiter...
Wait for `.notify`. Returns a `.Future` that resolves ``True`` if the condition is notified, or ``False`` after a timeout.
[ "Wait", "for", ".", "notify", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L124-L142
train
tornadoweb/tornado
tornado/locks.py
Condition.notify
def notify(self, n: int = 1) -> None: """Wake ``n`` waiters.""" waiters = [] # Waiters we plan to run right now. while n and self._waiters: waiter = self._waiters.popleft() if not waiter.done(): # Might have timed out. n -= 1 waiters.appe...
python
def notify(self, n: int = 1) -> None: """Wake ``n`` waiters.""" waiters = [] # Waiters we plan to run right now. while n and self._waiters: waiter = self._waiters.popleft() if not waiter.done(): # Might have timed out. n -= 1 waiters.appe...
[ "def", "notify", "(", "self", ",", "n", ":", "int", "=", "1", ")", "->", "None", ":", "waiters", "=", "[", "]", "# Waiters we plan to run right now.", "while", "n", "and", "self", ".", "_waiters", ":", "waiter", "=", "self", ".", "_waiters", ".", "popl...
Wake ``n`` waiters.
[ "Wake", "n", "waiters", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L144-L154
train
tornadoweb/tornado
tornado/locks.py
Event.set
def set(self) -> None: """Set the internal flag to ``True``. All waiters are awakened. Calling `.wait` once the flag is set will not block. """ if not self._value: self._value = True for fut in self._waiters: if not fut.done(): ...
python
def set(self) -> None: """Set the internal flag to ``True``. All waiters are awakened. Calling `.wait` once the flag is set will not block. """ if not self._value: self._value = True for fut in self._waiters: if not fut.done(): ...
[ "def", "set", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "_value", ":", "self", ".", "_value", "=", "True", "for", "fut", "in", "self", ".", "_waiters", ":", "if", "not", "fut", ".", "done", "(", ")", ":", "fut", ".", "set_r...
Set the internal flag to ``True``. All waiters are awakened. Calling `.wait` once the flag is set will not block.
[ "Set", "the", "internal", "flag", "to", "True", ".", "All", "waiters", "are", "awakened", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L215-L225
train
tornadoweb/tornado
tornado/locks.py
Event.wait
def wait(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[None]: """Block until the internal flag is true. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout. """ fut = Future() # type: Future[None] if self._value: ...
python
def wait(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[None]: """Block until the internal flag is true. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout. """ fut = Future() # type: Future[None] if self._value: ...
[ "def", "wait", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "None", "]", ":", "fut", "=", "Future", "(", ")", "# type: Future[None]", "if", "self", ".", "_v...
Block until the internal flag is true. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout.
[ "Block", "until", "the", "internal", "flag", "is", "true", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L234-L258
train
tornadoweb/tornado
tornado/locks.py
Semaphore.release
def release(self) -> None: """Increment the counter and wake one waiter.""" self._value += 1 while self._waiters: waiter = self._waiters.popleft() if not waiter.done(): self._value -= 1 # If the waiter is a coroutine paused at ...
python
def release(self) -> None: """Increment the counter and wake one waiter.""" self._value += 1 while self._waiters: waiter = self._waiters.popleft() if not waiter.done(): self._value -= 1 # If the waiter is a coroutine paused at ...
[ "def", "release", "(", "self", ")", "->", "None", ":", "self", ".", "_value", "+=", "1", "while", "self", ".", "_waiters", ":", "waiter", "=", "self", ".", "_waiters", ".", "popleft", "(", ")", "if", "not", "waiter", ".", "done", "(", ")", ":", "...
Increment the counter and wake one waiter.
[ "Increment", "the", "counter", "and", "wake", "one", "waiter", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L397-L412
train
tornadoweb/tornado
tornado/locks.py
Semaphore.acquire
def acquire( self, timeout: Union[float, datetime.timedelta] = None ) -> Awaitable[_ReleasingContextManager]: """Decrement the counter. Returns an awaitable. Block if the counter is zero and wait for a `.release`. The awaitable raises `.TimeoutError` after the deadline. """ ...
python
def acquire( self, timeout: Union[float, datetime.timedelta] = None ) -> Awaitable[_ReleasingContextManager]: """Decrement the counter. Returns an awaitable. Block if the counter is zero and wait for a `.release`. The awaitable raises `.TimeoutError` after the deadline. """ ...
[ "def", "acquire", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "_ReleasingContextManager", "]", ":", "waiter", "=", "Future", "(", ")", "# type: Future[_ReleasingCo...
Decrement the counter. Returns an awaitable. Block if the counter is zero and wait for a `.release`. The awaitable raises `.TimeoutError` after the deadline.
[ "Decrement", "the", "counter", ".", "Returns", "an", "awaitable", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L414-L440
train
tornadoweb/tornado
tornado/locks.py
BoundedSemaphore.release
def release(self) -> None: """Increment the counter and wake one waiter.""" if self._value >= self._initial_value: raise ValueError("Semaphore released too many times") super(BoundedSemaphore, self).release()
python
def release(self) -> None: """Increment the counter and wake one waiter.""" if self._value >= self._initial_value: raise ValueError("Semaphore released too many times") super(BoundedSemaphore, self).release()
[ "def", "release", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_value", ">=", "self", ".", "_initial_value", ":", "raise", "ValueError", "(", "\"Semaphore released too many times\"", ")", "super", "(", "BoundedSemaphore", ",", "self", ")", ".", "...
Increment the counter and wake one waiter.
[ "Increment", "the", "counter", "and", "wake", "one", "waiter", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L478-L482
train
tornadoweb/tornado
tornado/locks.py
Lock.acquire
def acquire( self, timeout: Union[float, datetime.timedelta] = None ) -> Awaitable[_ReleasingContextManager]: """Attempt to lock. Returns an awaitable. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout. """ return self._block.acquire(time...
python
def acquire( self, timeout: Union[float, datetime.timedelta] = None ) -> Awaitable[_ReleasingContextManager]: """Attempt to lock. Returns an awaitable. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout. """ return self._block.acquire(time...
[ "def", "acquire", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "_ReleasingContextManager", "]", ":", "return", "self", ".", "_block", ".", "acquire", "(", "time...
Attempt to lock. Returns an awaitable. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout.
[ "Attempt", "to", "lock", ".", "Returns", "an", "awaitable", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L528-L536
train
tornadoweb/tornado
tornado/http1connection.py
HTTP1Connection.read_response
def read_response(self, delegate: httputil.HTTPMessageDelegate) -> Awaitable[bool]: """Read a single HTTP response. Typical client-mode usage is to write a request using `write_headers`, `write`, and `finish`, and then call ``read_response``. :arg delegate: a `.HTTPMessageDelegate` ...
python
def read_response(self, delegate: httputil.HTTPMessageDelegate) -> Awaitable[bool]: """Read a single HTTP response. Typical client-mode usage is to write a request using `write_headers`, `write`, and `finish`, and then call ``read_response``. :arg delegate: a `.HTTPMessageDelegate` ...
[ "def", "read_response", "(", "self", ",", "delegate", ":", "httputil", ".", "HTTPMessageDelegate", ")", "->", "Awaitable", "[", "bool", "]", ":", "if", "self", ".", "params", ".", "decompress", ":", "delegate", "=", "_GzipMessageDelegate", "(", "delegate", "...
Read a single HTTP response. Typical client-mode usage is to write a request using `write_headers`, `write`, and `finish`, and then call ``read_response``. :arg delegate: a `.HTTPMessageDelegate` Returns a `.Future` that resolves to a bool after the full response has been read...
[ "Read", "a", "single", "HTTP", "response", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L165-L178
train
tornadoweb/tornado
tornado/http1connection.py
HTTP1Connection._clear_callbacks
def _clear_callbacks(self) -> None: """Clears the callback attributes. This allows the request handler to be garbage collected more quickly in CPython by breaking up reference cycles. """ self._write_callback = None self._write_future = None # type: Optional[Future[None...
python
def _clear_callbacks(self) -> None: """Clears the callback attributes. This allows the request handler to be garbage collected more quickly in CPython by breaking up reference cycles. """ self._write_callback = None self._write_future = None # type: Optional[Future[None...
[ "def", "_clear_callbacks", "(", "self", ")", "->", "None", ":", "self", ".", "_write_callback", "=", "None", "self", ".", "_write_future", "=", "None", "# type: Optional[Future[None]]", "self", ".", "_close_callback", "=", "None", "# type: Optional[Callable[[], None]]...
Clears the callback attributes. This allows the request handler to be garbage collected more quickly in CPython by breaking up reference cycles.
[ "Clears", "the", "callback", "attributes", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L302-L312
train
tornadoweb/tornado
tornado/http1connection.py
HTTP1Connection.detach
def detach(self) -> iostream.IOStream: """Take control of the underlying stream. Returns the underlying `.IOStream` object and stops all further HTTP processing. May only be called during `.HTTPMessageDelegate.headers_received`. Intended for implementing protocols like websock...
python
def detach(self) -> iostream.IOStream: """Take control of the underlying stream. Returns the underlying `.IOStream` object and stops all further HTTP processing. May only be called during `.HTTPMessageDelegate.headers_received`. Intended for implementing protocols like websock...
[ "def", "detach", "(", "self", ")", "->", "iostream", ".", "IOStream", ":", "self", ".", "_clear_callbacks", "(", ")", "stream", "=", "self", ".", "stream", "self", ".", "stream", "=", "None", "# type: ignore", "if", "not", "self", ".", "_finish_future", ...
Take control of the underlying stream. Returns the underlying `.IOStream` object and stops all further HTTP processing. May only be called during `.HTTPMessageDelegate.headers_received`. Intended for implementing protocols like websockets that tunnel over an HTTP handshake.
[ "Take", "control", "of", "the", "underlying", "stream", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L347-L360
train
tornadoweb/tornado
tornado/http1connection.py
HTTP1Connection.write_headers
def write_headers( self, start_line: Union[httputil.RequestStartLine, httputil.ResponseStartLine], headers: httputil.HTTPHeaders, chunk: bytes = None, ) -> "Future[None]": """Implements `.HTTPConnection.write_headers`.""" lines = [] if self.is_client: ...
python
def write_headers( self, start_line: Union[httputil.RequestStartLine, httputil.ResponseStartLine], headers: httputil.HTTPHeaders, chunk: bytes = None, ) -> "Future[None]": """Implements `.HTTPConnection.write_headers`.""" lines = [] if self.is_client: ...
[ "def", "write_headers", "(", "self", ",", "start_line", ":", "Union", "[", "httputil", ".", "RequestStartLine", ",", "httputil", ".", "ResponseStartLine", "]", ",", "headers", ":", "httputil", ".", "HTTPHeaders", ",", "chunk", ":", "bytes", "=", "None", ",",...
Implements `.HTTPConnection.write_headers`.
[ "Implements", ".", "HTTPConnection", ".", "write_headers", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L376-L465
train
tornadoweb/tornado
tornado/http1connection.py
HTTP1Connection.write
def write(self, chunk: bytes) -> "Future[None]": """Implements `.HTTPConnection.write`. For backwards compatibility it is allowed but deprecated to skip `write_headers` and instead call `write()` with a pre-encoded header block. """ future = None if self.stream.c...
python
def write(self, chunk: bytes) -> "Future[None]": """Implements `.HTTPConnection.write`. For backwards compatibility it is allowed but deprecated to skip `write_headers` and instead call `write()` with a pre-encoded header block. """ future = None if self.stream.c...
[ "def", "write", "(", "self", ",", "chunk", ":", "bytes", ")", "->", "\"Future[None]\"", ":", "future", "=", "None", "if", "self", ".", "stream", ".", "closed", "(", ")", ":", "future", "=", "self", ".", "_write_future", "=", "Future", "(", ")", "self...
Implements `.HTTPConnection.write`. For backwards compatibility it is allowed but deprecated to skip `write_headers` and instead call `write()` with a pre-encoded header block.
[ "Implements", ".", "HTTPConnection", ".", "write", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L483-L499
train
tornadoweb/tornado
tornado/http1connection.py
HTTP1Connection.finish
def finish(self) -> None: """Implements `.HTTPConnection.finish`.""" if ( self._expected_content_remaining is not None and self._expected_content_remaining != 0 and not self.stream.closed() ): self.stream.close() raise httputil.HTTPOutp...
python
def finish(self) -> None: """Implements `.HTTPConnection.finish`.""" if ( self._expected_content_remaining is not None and self._expected_content_remaining != 0 and not self.stream.closed() ): self.stream.close() raise httputil.HTTPOutp...
[ "def", "finish", "(", "self", ")", "->", "None", ":", "if", "(", "self", ".", "_expected_content_remaining", "is", "not", "None", "and", "self", ".", "_expected_content_remaining", "!=", "0", "and", "not", "self", ".", "stream", ".", "closed", "(", ")", ...
Implements `.HTTPConnection.finish`.
[ "Implements", ".", "HTTPConnection", ".", "finish", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L501-L531
train
tornadoweb/tornado
tornado/http1connection.py
HTTP1ServerConnection.close
async def close(self) -> None: """Closes the connection. Returns a `.Future` that resolves after the serving loop has exited. """ self.stream.close() # Block until the serving loop is done, but ignore any exceptions # (start_serving is already responsible for logging the...
python
async def close(self) -> None: """Closes the connection. Returns a `.Future` that resolves after the serving loop has exited. """ self.stream.close() # Block until the serving loop is done, but ignore any exceptions # (start_serving is already responsible for logging the...
[ "async", "def", "close", "(", "self", ")", "->", "None", ":", "self", ".", "stream", ".", "close", "(", ")", "# Block until the serving loop is done, but ignore any exceptions", "# (start_serving is already responsible for logging them).", "assert", "self", ".", "_serving_f...
Closes the connection. Returns a `.Future` that resolves after the serving loop has exited.
[ "Closes", "the", "connection", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L784-L796
train
tornadoweb/tornado
tornado/http1connection.py
HTTP1ServerConnection.start_serving
def start_serving(self, delegate: httputil.HTTPServerConnectionDelegate) -> None: """Starts serving requests on this connection. :arg delegate: a `.HTTPServerConnectionDelegate` """ assert isinstance(delegate, httputil.HTTPServerConnectionDelegate) fut = gen.convert_yielded(self...
python
def start_serving(self, delegate: httputil.HTTPServerConnectionDelegate) -> None: """Starts serving requests on this connection. :arg delegate: a `.HTTPServerConnectionDelegate` """ assert isinstance(delegate, httputil.HTTPServerConnectionDelegate) fut = gen.convert_yielded(self...
[ "def", "start_serving", "(", "self", ",", "delegate", ":", "httputil", ".", "HTTPServerConnectionDelegate", ")", "->", "None", ":", "assert", "isinstance", "(", "delegate", ",", "httputil", ".", "HTTPServerConnectionDelegate", ")", "fut", "=", "gen", ".", "conve...
Starts serving requests on this connection. :arg delegate: a `.HTTPServerConnectionDelegate`
[ "Starts", "serving", "requests", "on", "this", "connection", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L798-L807
train
tornadoweb/tornado
tornado/websocket.py
websocket_connect
def websocket_connect( url: Union[str, httpclient.HTTPRequest], callback: Callable[["Future[WebSocketClientConnection]"], None] = None, connect_timeout: float = None, on_message_callback: Callable[[Union[None, str, bytes]], None] = None, compression_options: Dict[str, Any] = None, ping_interval:...
python
def websocket_connect( url: Union[str, httpclient.HTTPRequest], callback: Callable[["Future[WebSocketClientConnection]"], None] = None, connect_timeout: float = None, on_message_callback: Callable[[Union[None, str, bytes]], None] = None, compression_options: Dict[str, Any] = None, ping_interval:...
[ "def", "websocket_connect", "(", "url", ":", "Union", "[", "str", ",", "httpclient", ".", "HTTPRequest", "]", ",", "callback", ":", "Callable", "[", "[", "\"Future[WebSocketClientConnection]\"", "]", ",", "None", "]", "=", "None", ",", "connect_timeout", ":", ...
Client-side websocket support. Takes a url and returns a Future whose result is a `WebSocketClientConnection`. ``compression_options`` is interpreted in the same way as the return value of `.WebSocketHandler.get_compression_options`. The connection supports two styles of operation. In the corouti...
[ "Client", "-", "side", "websocket", "support", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1586-L1663
train
tornadoweb/tornado
tornado/websocket.py
WebSocketHandler.write_message
def write_message( self, message: Union[bytes, str, Dict[str, Any]], binary: bool = False ) -> "Future[None]": """Sends the given message to the client of this Web Socket. The message may be either a string or a dict (which will be encoded as json). If the ``binary`` argument is fa...
python
def write_message( self, message: Union[bytes, str, Dict[str, Any]], binary: bool = False ) -> "Future[None]": """Sends the given message to the client of this Web Socket. The message may be either a string or a dict (which will be encoded as json). If the ``binary`` argument is fa...
[ "def", "write_message", "(", "self", ",", "message", ":", "Union", "[", "bytes", ",", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]", ",", "binary", ":", "bool", "=", "False", ")", "->", "\"Future[None]\"", ":", "if", "self", ".", "ws_connectio...
Sends the given message to the client of this Web Socket. The message may be either a string or a dict (which will be encoded as json). If the ``binary`` argument is false, the message will be sent as utf8; in binary mode any byte string is allowed. If the connection is alread...
[ "Sends", "the", "given", "message", "to", "the", "client", "of", "this", "Web", "Socket", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L314-L342
train
tornadoweb/tornado
tornado/websocket.py
WebSocketHandler.ping
def ping(self, data: Union[str, bytes] = b"") -> None: """Send ping frame to the remote end. The data argument allows a small amount of data (up to 125 bytes) to be sent as a part of the ping message. Note that not all websocket implementations expose this data to applications. ...
python
def ping(self, data: Union[str, bytes] = b"") -> None: """Send ping frame to the remote end. The data argument allows a small amount of data (up to 125 bytes) to be sent as a part of the ping message. Note that not all websocket implementations expose this data to applications. ...
[ "def", "ping", "(", "self", ",", "data", ":", "Union", "[", "str", ",", "bytes", "]", "=", "b\"\"", ")", "->", "None", ":", "data", "=", "utf8", "(", "data", ")", "if", "self", ".", "ws_connection", "is", "None", "or", "self", ".", "ws_connection",...
Send ping frame to the remote end. The data argument allows a small amount of data (up to 125 bytes) to be sent as a part of the ping message. Note that not all websocket implementations expose this data to applications. Consider using the ``websocket_ping_interval`` applicatio...
[ "Send", "ping", "frame", "to", "the", "remote", "end", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L429-L448
train
tornadoweb/tornado
tornado/websocket.py
WebSocketHandler.close
def close(self, code: int = None, reason: str = None) -> None: """Closes this Web Socket. Once the close handshake is successful the socket will be closed. ``code`` may be a numeric status code, taken from the values defined in `RFC 6455 section 7.4.1 <https://tools.ietf.org/ht...
python
def close(self, code: int = None, reason: str = None) -> None: """Closes this Web Socket. Once the close handshake is successful the socket will be closed. ``code`` may be a numeric status code, taken from the values defined in `RFC 6455 section 7.4.1 <https://tools.ietf.org/ht...
[ "def", "close", "(", "self", ",", "code", ":", "int", "=", "None", ",", "reason", ":", "str", "=", "None", ")", "->", "None", ":", "if", "self", ".", "ws_connection", ":", "self", ".", "ws_connection", ".", "close", "(", "code", ",", "reason", ")",...
Closes this Web Socket. Once the close handshake is successful the socket will be closed. ``code`` may be a numeric status code, taken from the values defined in `RFC 6455 section 7.4.1 <https://tools.ietf.org/html/rfc6455#section-7.4.1>`_. ``reason`` may be a textual message a...
[ "Closes", "this", "Web", "Socket", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L471-L489
train
tornadoweb/tornado
tornado/websocket.py
WebSocketHandler.check_origin
def check_origin(self, origin: str) -> bool: """Override to enable support for allowing alternate origins. The ``origin`` argument is the value of the ``Origin`` HTTP header, the url responsible for initiating this request. This method is not called for clients that do not send this he...
python
def check_origin(self, origin: str) -> bool: """Override to enable support for allowing alternate origins. The ``origin`` argument is the value of the ``Origin`` HTTP header, the url responsible for initiating this request. This method is not called for clients that do not send this he...
[ "def", "check_origin", "(", "self", ",", "origin", ":", "str", ")", "->", "bool", ":", "parsed_origin", "=", "urlparse", "(", "origin", ")", "origin", "=", "parsed_origin", ".", "netloc", "origin", "=", "origin", ".", "lower", "(", ")", "host", "=", "s...
Override to enable support for allowing alternate origins. The ``origin`` argument is the value of the ``Origin`` HTTP header, the url responsible for initiating this request. This method is not called for clients that do not send this header; such requests are always allowed (because ...
[ "Override", "to", "enable", "support", "for", "allowing", "alternate", "origins", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L491-L545
train
tornadoweb/tornado
tornado/websocket.py
WebSocketHandler.set_nodelay
def set_nodelay(self, value: bool) -> None: """Set the no-delay flag for this stream. By default, small messages may be delayed and/or combined to minimize the number of packets sent. This can sometimes cause 200-500ms delays due to the interaction between Nagle's algorithm and TCP del...
python
def set_nodelay(self, value: bool) -> None: """Set the no-delay flag for this stream. By default, small messages may be delayed and/or combined to minimize the number of packets sent. This can sometimes cause 200-500ms delays due to the interaction between Nagle's algorithm and TCP del...
[ "def", "set_nodelay", "(", "self", ",", "value", ":", "bool", ")", "->", "None", ":", "assert", "self", ".", "ws_connection", "is", "not", "None", "self", ".", "ws_connection", ".", "set_nodelay", "(", "value", ")" ]
Set the no-delay flag for this stream. By default, small messages may be delayed and/or combined to minimize the number of packets sent. This can sometimes cause 200-500ms delays due to the interaction between Nagle's algorithm and TCP delayed ACKs. To reduce this delay (at the expens...
[ "Set", "the", "no", "-", "delay", "flag", "for", "this", "stream", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L547-L562
train
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol._run_callback
def _run_callback( self, callback: Callable, *args: Any, **kwargs: Any ) -> "Optional[Future[Any]]": """Runs the given callback with exception handling. If the callback is a coroutine, returns its Future. On error, aborts the websocket connection and returns None. """ ...
python
def _run_callback( self, callback: Callable, *args: Any, **kwargs: Any ) -> "Optional[Future[Any]]": """Runs the given callback with exception handling. If the callback is a coroutine, returns its Future. On error, aborts the websocket connection and returns None. """ ...
[ "def", "_run_callback", "(", "self", ",", "callback", ":", "Callable", ",", "*", "args", ":", "Any", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "\"Optional[Future[Any]]\"", ":", "try", ":", "result", "=", "callback", "(", "*", "args", ",", "*", ...
Runs the given callback with exception handling. If the callback is a coroutine, returns its Future. On error, aborts the websocket connection and returns None.
[ "Runs", "the", "given", "callback", "with", "exception", "handling", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L640-L659
train
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol._abort
def _abort(self) -> None: """Instantly aborts the WebSocket connection by closing the socket""" self.client_terminated = True self.server_terminated = True if self.stream is not None: self.stream.close() # forcibly tear down the connection self.close()
python
def _abort(self) -> None: """Instantly aborts the WebSocket connection by closing the socket""" self.client_terminated = True self.server_terminated = True if self.stream is not None: self.stream.close() # forcibly tear down the connection self.close()
[ "def", "_abort", "(", "self", ")", "->", "None", ":", "self", ".", "client_terminated", "=", "True", "self", ".", "server_terminated", "=", "True", "if", "self", ".", "stream", "is", "not", "None", ":", "self", ".", "stream", ".", "close", "(", ")", ...
Instantly aborts the WebSocket connection by closing the socket
[ "Instantly", "aborts", "the", "WebSocket", "connection", "by", "closing", "the", "socket" ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L664-L670
train
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13._handle_websocket_headers
def _handle_websocket_headers(self, handler: WebSocketHandler) -> None: """Verifies all invariant- and required headers If a header is missing or have an incorrect value ValueError will be raised """ fields = ("Host", "Sec-Websocket-Key", "Sec-Websocket-Version") if not ...
python
def _handle_websocket_headers(self, handler: WebSocketHandler) -> None: """Verifies all invariant- and required headers If a header is missing or have an incorrect value ValueError will be raised """ fields = ("Host", "Sec-Websocket-Key", "Sec-Websocket-Version") if not ...
[ "def", "_handle_websocket_headers", "(", "self", ",", "handler", ":", "WebSocketHandler", ")", "->", "None", ":", "fields", "=", "(", "\"Host\"", ",", "\"Sec-Websocket-Key\"", ",", "\"Sec-Websocket-Version\"", ")", "if", "not", "all", "(", "map", "(", "lambda", ...
Verifies all invariant- and required headers If a header is missing or have an incorrect value ValueError will be raised
[ "Verifies", "all", "invariant", "-", "and", "required", "headers" ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L890-L898
train
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13.compute_accept_value
def compute_accept_value(key: Union[str, bytes]) -> str: """Computes the value for the Sec-WebSocket-Accept header, given the value for Sec-WebSocket-Key. """ sha1 = hashlib.sha1() sha1.update(utf8(key)) sha1.update(b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11") # Magic value ...
python
def compute_accept_value(key: Union[str, bytes]) -> str: """Computes the value for the Sec-WebSocket-Accept header, given the value for Sec-WebSocket-Key. """ sha1 = hashlib.sha1() sha1.update(utf8(key)) sha1.update(b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11") # Magic value ...
[ "def", "compute_accept_value", "(", "key", ":", "Union", "[", "str", ",", "bytes", "]", ")", "->", "str", ":", "sha1", "=", "hashlib", ".", "sha1", "(", ")", "sha1", ".", "update", "(", "utf8", "(", "key", ")", ")", "sha1", ".", "update", "(", "b...
Computes the value for the Sec-WebSocket-Accept header, given the value for Sec-WebSocket-Key.
[ "Computes", "the", "value", "for", "the", "Sec", "-", "WebSocket", "-", "Accept", "header", "given", "the", "value", "for", "Sec", "-", "WebSocket", "-", "Key", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L901-L908
train
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13._process_server_headers
def _process_server_headers( self, key: Union[str, bytes], headers: httputil.HTTPHeaders ) -> None: """Process the headers sent by the server to this client connection. 'key' is the websocket handshake challenge/response key. """ assert headers["Upgrade"].lower() == "websock...
python
def _process_server_headers( self, key: Union[str, bytes], headers: httputil.HTTPHeaders ) -> None: """Process the headers sent by the server to this client connection. 'key' is the websocket handshake challenge/response key. """ assert headers["Upgrade"].lower() == "websock...
[ "def", "_process_server_headers", "(", "self", ",", "key", ":", "Union", "[", "str", ",", "bytes", "]", ",", "headers", ":", "httputil", ".", "HTTPHeaders", ")", "->", "None", ":", "assert", "headers", "[", "\"Upgrade\"", "]", ".", "lower", "(", ")", "...
Process the headers sent by the server to this client connection. 'key' is the websocket handshake challenge/response key.
[ "Process", "the", "headers", "sent", "by", "the", "server", "to", "this", "client", "connection", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L974-L993
train
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13._get_compressor_options
def _get_compressor_options( self, side: str, agreed_parameters: Dict[str, Any], compression_options: Dict[str, Any] = None, ) -> Dict[str, Any]: """Converts a websocket agreed_parameters set to keyword arguments for our compressor objects. """ options...
python
def _get_compressor_options( self, side: str, agreed_parameters: Dict[str, Any], compression_options: Dict[str, Any] = None, ) -> Dict[str, Any]: """Converts a websocket agreed_parameters set to keyword arguments for our compressor objects. """ options...
[ "def", "_get_compressor_options", "(", "self", ",", "side", ":", "str", ",", "agreed_parameters", ":", "Dict", "[", "str", ",", "Any", "]", ",", "compression_options", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ",", ")", "->", "Dict", "[", ...
Converts a websocket agreed_parameters set to keyword arguments for our compressor objects.
[ "Converts", "a", "websocket", "agreed_parameters", "set", "to", "keyword", "arguments", "for", "our", "compressor", "objects", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L995-L1013
train
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13.write_message
def write_message( self, message: Union[str, bytes], binary: bool = False ) -> "Future[None]": """Sends the given message to the client of this Web Socket.""" if binary: opcode = 0x2 else: opcode = 0x1 message = tornado.escape.utf8(message) ass...
python
def write_message( self, message: Union[str, bytes], binary: bool = False ) -> "Future[None]": """Sends the given message to the client of this Web Socket.""" if binary: opcode = 0x2 else: opcode = 0x1 message = tornado.escape.utf8(message) ass...
[ "def", "write_message", "(", "self", ",", "message", ":", "Union", "[", "str", ",", "bytes", "]", ",", "binary", ":", "bool", "=", "False", ")", "->", "\"Future[None]\"", ":", "if", "binary", ":", "opcode", "=", "0x2", "else", ":", "opcode", "=", "0x...
Sends the given message to the client of this Web Socket.
[ "Sends", "the", "given", "message", "to", "the", "client", "of", "this", "Web", "Socket", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1077-L1108
train
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13.write_ping
def write_ping(self, data: bytes) -> None: """Send ping frame.""" assert isinstance(data, bytes) self._write_frame(True, 0x9, data)
python
def write_ping(self, data: bytes) -> None: """Send ping frame.""" assert isinstance(data, bytes) self._write_frame(True, 0x9, data)
[ "def", "write_ping", "(", "self", ",", "data", ":", "bytes", ")", "->", "None", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "self", ".", "_write_frame", "(", "True", ",", "0x9", ",", "data", ")" ]
Send ping frame.
[ "Send", "ping", "frame", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1110-L1113
train
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13._handle_message
def _handle_message(self, opcode: int, data: bytes) -> "Optional[Future[None]]": """Execute on_message, returning its Future if it is a coroutine.""" if self.client_terminated: return None if self._frame_compressed: assert self._decompressor is not None try: ...
python
def _handle_message(self, opcode: int, data: bytes) -> "Optional[Future[None]]": """Execute on_message, returning its Future if it is a coroutine.""" if self.client_terminated: return None if self._frame_compressed: assert self._decompressor is not None try: ...
[ "def", "_handle_message", "(", "self", ",", "opcode", ":", "int", ",", "data", ":", "bytes", ")", "->", "\"Optional[Future[None]]\"", ":", "if", "self", ".", "client_terminated", ":", "return", "None", "if", "self", ".", "_frame_compressed", ":", "assert", "...
Execute on_message, returning its Future if it is a coroutine.
[ "Execute", "on_message", "returning", "its", "Future", "if", "it", "is", "a", "coroutine", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1211-L1260
train
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13.close
def close(self, code: int = None, reason: str = None) -> None: """Closes the WebSocket connection.""" if not self.server_terminated: if not self.stream.closed(): if code is None and reason is not None: code = 1000 # "normal closure" status code ...
python
def close(self, code: int = None, reason: str = None) -> None: """Closes the WebSocket connection.""" if not self.server_terminated: if not self.stream.closed(): if code is None and reason is not None: code = 1000 # "normal closure" status code ...
[ "def", "close", "(", "self", ",", "code", ":", "int", "=", "None", ",", "reason", ":", "str", "=", "None", ")", "->", "None", ":", "if", "not", "self", ".", "server_terminated", ":", "if", "not", "self", ".", "stream", ".", "closed", "(", ")", ":...
Closes the WebSocket connection.
[ "Closes", "the", "WebSocket", "connection", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1262-L1289
train
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13.is_closing
def is_closing(self) -> bool: """Return ``True`` if this connection is closing. The connection is considered closing if either side has initiated its closing handshake or if the stream has been shut down uncleanly. """ return self.stream.closed() or self.client_terminate...
python
def is_closing(self) -> bool: """Return ``True`` if this connection is closing. The connection is considered closing if either side has initiated its closing handshake or if the stream has been shut down uncleanly. """ return self.stream.closed() or self.client_terminate...
[ "def", "is_closing", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "stream", ".", "closed", "(", ")", "or", "self", ".", "client_terminated", "or", "self", ".", "server_terminated" ]
Return ``True`` if this connection is closing. The connection is considered closing if either side has initiated its closing handshake or if the stream has been shut down uncleanly.
[ "Return", "True", "if", "this", "connection", "is", "closing", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1291-L1298
train
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13.start_pinging
def start_pinging(self) -> None: """Start sending periodic pings to keep the connection alive""" assert self.ping_interval is not None if self.ping_interval > 0: self.last_ping = self.last_pong = IOLoop.current().time() self.ping_callback = PeriodicCallback( ...
python
def start_pinging(self) -> None: """Start sending periodic pings to keep the connection alive""" assert self.ping_interval is not None if self.ping_interval > 0: self.last_ping = self.last_pong = IOLoop.current().time() self.ping_callback = PeriodicCallback( ...
[ "def", "start_pinging", "(", "self", ")", "->", "None", ":", "assert", "self", ".", "ping_interval", "is", "not", "None", "if", "self", ".", "ping_interval", ">", "0", ":", "self", ".", "last_ping", "=", "self", ".", "last_pong", "=", "IOLoop", ".", "c...
Start sending periodic pings to keep the connection alive
[ "Start", "sending", "periodic", "pings", "to", "keep", "the", "connection", "alive" ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1315-L1323
train
tornadoweb/tornado
tornado/websocket.py
WebSocketProtocol13.periodic_ping
def periodic_ping(self) -> None: """Send a ping to keep the websocket alive Called periodically if the websocket_ping_interval is set and non-zero. """ if self.is_closing() and self.ping_callback is not None: self.ping_callback.stop() return # Check for ...
python
def periodic_ping(self) -> None: """Send a ping to keep the websocket alive Called periodically if the websocket_ping_interval is set and non-zero. """ if self.is_closing() and self.ping_callback is not None: self.ping_callback.stop() return # Check for ...
[ "def", "periodic_ping", "(", "self", ")", "->", "None", ":", "if", "self", ".", "is_closing", "(", ")", "and", "self", ".", "ping_callback", "is", "not", "None", ":", "self", ".", "ping_callback", ".", "stop", "(", ")", "return", "# Check for timeout on po...
Send a ping to keep the websocket alive Called periodically if the websocket_ping_interval is set and non-zero.
[ "Send", "a", "ping", "to", "keep", "the", "websocket", "alive" ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1325-L1350
train
tornadoweb/tornado
tornado/websocket.py
WebSocketClientConnection.close
def close(self, code: int = None, reason: str = None) -> None: """Closes the websocket connection. ``code`` and ``reason`` are documented under `WebSocketHandler.close`. .. versionadded:: 3.2 .. versionchanged:: 4.0 Added the ``code`` and ``reason`` arguments. ...
python
def close(self, code: int = None, reason: str = None) -> None: """Closes the websocket connection. ``code`` and ``reason`` are documented under `WebSocketHandler.close`. .. versionadded:: 3.2 .. versionchanged:: 4.0 Added the ``code`` and ``reason`` arguments. ...
[ "def", "close", "(", "self", ",", "code", ":", "int", "=", "None", ",", "reason", ":", "str", "=", "None", ")", "->", "None", ":", "if", "self", ".", "protocol", "is", "not", "None", ":", "self", ".", "protocol", ".", "close", "(", "code", ",", ...
Closes the websocket connection. ``code`` and ``reason`` are documented under `WebSocketHandler.close`. .. versionadded:: 3.2 .. versionchanged:: 4.0 Added the ``code`` and ``reason`` arguments.
[ "Closes", "the", "websocket", "connection", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1423-L1437
train
tornadoweb/tornado
tornado/websocket.py
WebSocketClientConnection.write_message
def write_message( self, message: Union[str, bytes], binary: bool = False ) -> "Future[None]": """Sends a message to the WebSocket server. If the stream is closed, raises `WebSocketClosedError`. Returns a `.Future` which can be used for flow control. .. versionchanged:: 5.0...
python
def write_message( self, message: Union[str, bytes], binary: bool = False ) -> "Future[None]": """Sends a message to the WebSocket server. If the stream is closed, raises `WebSocketClosedError`. Returns a `.Future` which can be used for flow control. .. versionchanged:: 5.0...
[ "def", "write_message", "(", "self", ",", "message", ":", "Union", "[", "str", ",", "bytes", "]", ",", "binary", ":", "bool", "=", "False", ")", "->", "\"Future[None]\"", ":", "return", "self", ".", "protocol", ".", "write_message", "(", "message", ",", ...
Sends a message to the WebSocket server. If the stream is closed, raises `WebSocketClosedError`. Returns a `.Future` which can be used for flow control. .. versionchanged:: 5.0 Exception raised on a closed stream changed from `.StreamClosedError` to `WebSocketClosedError`...
[ "Sends", "a", "message", "to", "the", "WebSocket", "server", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1494-L1506
train
tornadoweb/tornado
tornado/websocket.py
WebSocketClientConnection.read_message
def read_message( self, callback: Callable[["Future[Union[None, str, bytes]]"], None] = None ) -> Awaitable[Union[None, str, bytes]]: """Reads a message from the WebSocket server. If on_message_callback was specified at WebSocket initialization, this function will never return messa...
python
def read_message( self, callback: Callable[["Future[Union[None, str, bytes]]"], None] = None ) -> Awaitable[Union[None, str, bytes]]: """Reads a message from the WebSocket server. If on_message_callback was specified at WebSocket initialization, this function will never return messa...
[ "def", "read_message", "(", "self", ",", "callback", ":", "Callable", "[", "[", "\"Future[Union[None, str, bytes]]\"", "]", ",", "None", "]", "=", "None", ")", "->", "Awaitable", "[", "Union", "[", "None", ",", "str", ",", "bytes", "]", "]", ":", "awaita...
Reads a message from the WebSocket server. If on_message_callback was specified at WebSocket initialization, this function will never return messages Returns a future whose result is the message, or None if the connection is closed. If a callback argument is given it will be c...
[ "Reads", "a", "message", "from", "the", "WebSocket", "server", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1508-L1525
train
tornadoweb/tornado
tornado/websocket.py
WebSocketClientConnection.ping
def ping(self, data: bytes = b"") -> None: """Send ping frame to the remote end. The data argument allows a small amount of data (up to 125 bytes) to be sent as a part of the ping message. Note that not all websocket implementations expose this data to applications. Con...
python
def ping(self, data: bytes = b"") -> None: """Send ping frame to the remote end. The data argument allows a small amount of data (up to 125 bytes) to be sent as a part of the ping message. Note that not all websocket implementations expose this data to applications. Con...
[ "def", "ping", "(", "self", ",", "data", ":", "bytes", "=", "b\"\"", ")", "->", "None", ":", "data", "=", "utf8", "(", "data", ")", "if", "self", ".", "protocol", "is", "None", ":", "raise", "WebSocketClosedError", "(", ")", "self", ".", "protocol", ...
Send ping frame to the remote end. The data argument allows a small amount of data (up to 125 bytes) to be sent as a part of the ping message. Note that not all websocket implementations expose this data to applications. Consider using the ``ping_interval`` argument to ...
[ "Send", "ping", "frame", "to", "the", "remote", "end", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1539-L1556
train
tornadoweb/tornado
tornado/options.py
define
def define( name: str, default: Any = None, type: type = None, help: str = None, metavar: str = None, multiple: bool = False, group: str = None, callback: Callable[[Any], None] = None, ) -> None: """Defines an option in the global namespace. See `OptionParser.define`. """ ...
python
def define( name: str, default: Any = None, type: type = None, help: str = None, metavar: str = None, multiple: bool = False, group: str = None, callback: Callable[[Any], None] = None, ) -> None: """Defines an option in the global namespace. See `OptionParser.define`. """ ...
[ "def", "define", "(", "name", ":", "str", ",", "default", ":", "Any", "=", "None", ",", "type", ":", "type", "=", "None", ",", "help", ":", "str", "=", "None", ",", "metavar", ":", "str", "=", "None", ",", "multiple", ":", "bool", "=", "False", ...
Defines an option in the global namespace. See `OptionParser.define`.
[ "Defines", "an", "option", "in", "the", "global", "namespace", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L667-L690
train
tornadoweb/tornado
tornado/options.py
parse_command_line
def parse_command_line(args: List[str] = None, final: bool = True) -> List[str]: """Parses global options from the command line. See `OptionParser.parse_command_line`. """ return options.parse_command_line(args, final=final)
python
def parse_command_line(args: List[str] = None, final: bool = True) -> List[str]: """Parses global options from the command line. See `OptionParser.parse_command_line`. """ return options.parse_command_line(args, final=final)
[ "def", "parse_command_line", "(", "args", ":", "List", "[", "str", "]", "=", "None", ",", "final", ":", "bool", "=", "True", ")", "->", "List", "[", "str", "]", ":", "return", "options", ".", "parse_command_line", "(", "args", ",", "final", "=", "fin...
Parses global options from the command line. See `OptionParser.parse_command_line`.
[ "Parses", "global", "options", "from", "the", "command", "line", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L693-L698
train
tornadoweb/tornado
tornado/options.py
parse_config_file
def parse_config_file(path: str, final: bool = True) -> None: """Parses global options from a config file. See `OptionParser.parse_config_file`. """ return options.parse_config_file(path, final=final)
python
def parse_config_file(path: str, final: bool = True) -> None: """Parses global options from a config file. See `OptionParser.parse_config_file`. """ return options.parse_config_file(path, final=final)
[ "def", "parse_config_file", "(", "path", ":", "str", ",", "final", ":", "bool", "=", "True", ")", "->", "None", ":", "return", "options", ".", "parse_config_file", "(", "path", ",", "final", "=", "final", ")" ]
Parses global options from a config file. See `OptionParser.parse_config_file`.
[ "Parses", "global", "options", "from", "a", "config", "file", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L701-L706
train
tornadoweb/tornado
tornado/options.py
OptionParser.items
def items(self) -> Iterable[Tuple[str, Any]]: """An iterable of (name, value) pairs. .. versionadded:: 3.1 """ return [(opt.name, opt.value()) for name, opt in self._options.items()]
python
def items(self) -> Iterable[Tuple[str, Any]]: """An iterable of (name, value) pairs. .. versionadded:: 3.1 """ return [(opt.name, opt.value()) for name, opt in self._options.items()]
[ "def", "items", "(", "self", ")", "->", "Iterable", "[", "Tuple", "[", "str", ",", "Any", "]", "]", ":", "return", "[", "(", "opt", ".", "name", ",", "opt", ".", "value", "(", ")", ")", "for", "name", ",", "opt", "in", "self", ".", "_options", ...
An iterable of (name, value) pairs. .. versionadded:: 3.1
[ "An", "iterable", "of", "(", "name", "value", ")", "pairs", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L166-L171
train
tornadoweb/tornado
tornado/options.py
OptionParser.groups
def groups(self) -> Set[str]: """The set of option-groups created by ``define``. .. versionadded:: 3.1 """ return set(opt.group_name for opt in self._options.values())
python
def groups(self) -> Set[str]: """The set of option-groups created by ``define``. .. versionadded:: 3.1 """ return set(opt.group_name for opt in self._options.values())
[ "def", "groups", "(", "self", ")", "->", "Set", "[", "str", "]", ":", "return", "set", "(", "opt", ".", "group_name", "for", "opt", "in", "self", ".", "_options", ".", "values", "(", ")", ")" ]
The set of option-groups created by ``define``. .. versionadded:: 3.1
[ "The", "set", "of", "option", "-", "groups", "created", "by", "define", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L173-L178
train
tornadoweb/tornado
tornado/options.py
OptionParser.group_dict
def group_dict(self, group: str) -> Dict[str, Any]: """The names and values of options in a group. Useful for copying options into Application settings:: from tornado.options import define, parse_command_line, options define('template_path', group='application') de...
python
def group_dict(self, group: str) -> Dict[str, Any]: """The names and values of options in a group. Useful for copying options into Application settings:: from tornado.options import define, parse_command_line, options define('template_path', group='application') de...
[ "def", "group_dict", "(", "self", ",", "group", ":", "str", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "dict", "(", "(", "opt", ".", "name", ",", "opt", ".", "value", "(", ")", ")", "for", "name", ",", "opt", "in", "self", ...
The names and values of options in a group. Useful for copying options into Application settings:: from tornado.options import define, parse_command_line, options define('template_path', group='application') define('static_path', group='application') parse_com...
[ "The", "names", "and", "values", "of", "options", "in", "a", "group", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L180-L201
train
tornadoweb/tornado
tornado/options.py
OptionParser.as_dict
def as_dict(self) -> Dict[str, Any]: """The names and values of all options. .. versionadded:: 3.1 """ return dict((opt.name, opt.value()) for name, opt in self._options.items())
python
def as_dict(self) -> Dict[str, Any]: """The names and values of all options. .. versionadded:: 3.1 """ return dict((opt.name, opt.value()) for name, opt in self._options.items())
[ "def", "as_dict", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "dict", "(", "(", "opt", ".", "name", ",", "opt", ".", "value", "(", ")", ")", "for", "name", ",", "opt", "in", "self", ".", "_options", ".", "items",...
The names and values of all options. .. versionadded:: 3.1
[ "The", "names", "and", "values", "of", "all", "options", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L203-L208
train
tornadoweb/tornado
tornado/options.py
OptionParser.define
def define( self, name: str, default: Any = None, type: type = None, help: str = None, metavar: str = None, multiple: bool = False, group: str = None, callback: Callable[[Any], None] = None, ) -> None: """Defines a new command line opti...
python
def define( self, name: str, default: Any = None, type: type = None, help: str = None, metavar: str = None, multiple: bool = False, group: str = None, callback: Callable[[Any], None] = None, ) -> None: """Defines a new command line opti...
[ "def", "define", "(", "self", ",", "name", ":", "str", ",", "default", ":", "Any", "=", "None", ",", "type", ":", "type", "=", "None", ",", "help", ":", "str", "=", "None", ",", "metavar", ":", "str", "=", "None", ",", "multiple", ":", "bool", ...
Defines a new command line option. ``type`` can be any of `str`, `int`, `float`, `bool`, `~datetime.datetime`, or `~datetime.timedelta`. If no ``type`` is given but a ``default`` is, ``type`` is the type of ``default``. Otherwise, ``type`` defaults to `str`. If ``multiple`` is ...
[ "Defines", "a", "new", "command", "line", "option", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L210-L295
train
tornadoweb/tornado
tornado/options.py
OptionParser.parse_command_line
def parse_command_line( self, args: List[str] = None, final: bool = True ) -> List[str]: """Parses all options given on the command line (defaults to `sys.argv`). Options look like ``--option=value`` and are parsed according to their ``type``. For boolean options, ``--option...
python
def parse_command_line( self, args: List[str] = None, final: bool = True ) -> List[str]: """Parses all options given on the command line (defaults to `sys.argv`). Options look like ``--option=value`` and are parsed according to their ``type``. For boolean options, ``--option...
[ "def", "parse_command_line", "(", "self", ",", "args", ":", "List", "[", "str", "]", "=", "None", ",", "final", ":", "bool", "=", "True", ")", "->", "List", "[", "str", "]", ":", "if", "args", "is", "None", ":", "args", "=", "sys", ".", "argv", ...
Parses all options given on the command line (defaults to `sys.argv`). Options look like ``--option=value`` and are parsed according to their ``type``. For boolean options, ``--option`` is equivalent to ``--option=true`` If the option has ``multiple=True``, comma-separated valu...
[ "Parses", "all", "options", "given", "on", "the", "command", "line", "(", "defaults", "to", "sys", ".", "argv", ")", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L297-L349
train
tornadoweb/tornado
tornado/options.py
OptionParser.parse_config_file
def parse_config_file(self, path: str, final: bool = True) -> None: """Parses and loads the config file at the given path. The config file contains Python code that will be executed (so it is **not safe** to use untrusted config files). Anything in the global namespace that matches a de...
python
def parse_config_file(self, path: str, final: bool = True) -> None: """Parses and loads the config file at the given path. The config file contains Python code that will be executed (so it is **not safe** to use untrusted config files). Anything in the global namespace that matches a de...
[ "def", "parse_config_file", "(", "self", ",", "path", ":", "str", ",", "final", ":", "bool", "=", "True", ")", "->", "None", ":", "config", "=", "{", "\"__file__\"", ":", "os", ".", "path", ".", "abspath", "(", "path", ")", "}", "with", "open", "("...
Parses and loads the config file at the given path. The config file contains Python code that will be executed (so it is **not safe** to use untrusted config files). Anything in the global namespace that matches a defined option will be used to set that option's value. Options ...
[ "Parses", "and", "loads", "the", "config", "file", "at", "the", "given", "path", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L351-L418
train
tornadoweb/tornado
tornado/options.py
OptionParser.print_help
def print_help(self, file: TextIO = None) -> None: """Prints all the command line options to stderr (or another file).""" if file is None: file = sys.stderr print("Usage: %s [OPTIONS]" % sys.argv[0], file=file) print("\nOptions:\n", file=file) by_group = {} # type: D...
python
def print_help(self, file: TextIO = None) -> None: """Prints all the command line options to stderr (or another file).""" if file is None: file = sys.stderr print("Usage: %s [OPTIONS]" % sys.argv[0], file=file) print("\nOptions:\n", file=file) by_group = {} # type: D...
[ "def", "print_help", "(", "self", ",", "file", ":", "TextIO", "=", "None", ")", "->", "None", ":", "if", "file", "is", "None", ":", "file", "=", "sys", ".", "stderr", "print", "(", "\"Usage: %s [OPTIONS]\"", "%", "sys", ".", "argv", "[", "0", "]", ...
Prints all the command line options to stderr (or another file).
[ "Prints", "all", "the", "command", "line", "options", "to", "stderr", "(", "or", "another", "file", ")", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L420-L448
train
tornadoweb/tornado
demos/blog/blog.py
BaseHandler.row_to_obj
def row_to_obj(self, row, cur): """Convert a SQL row to an object supporting dict and attribute access.""" obj = tornado.util.ObjectDict() for val, desc in zip(row, cur.description): obj[desc.name] = val return obj
python
def row_to_obj(self, row, cur): """Convert a SQL row to an object supporting dict and attribute access.""" obj = tornado.util.ObjectDict() for val, desc in zip(row, cur.description): obj[desc.name] = val return obj
[ "def", "row_to_obj", "(", "self", ",", "row", ",", "cur", ")", ":", "obj", "=", "tornado", ".", "util", ".", "ObjectDict", "(", ")", "for", "val", ",", "desc", "in", "zip", "(", "row", ",", "cur", ".", "description", ")", ":", "obj", "[", "desc",...
Convert a SQL row to an object supporting dict and attribute access.
[ "Convert", "a", "SQL", "row", "to", "an", "object", "supporting", "dict", "and", "attribute", "access", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/demos/blog/blog.py#L84-L89
train
tornadoweb/tornado
demos/blog/blog.py
BaseHandler.execute
async def execute(self, stmt, *args): """Execute a SQL statement. Must be called with ``await self.execute(...)`` """ with (await self.application.db.cursor()) as cur: await cur.execute(stmt, args)
python
async def execute(self, stmt, *args): """Execute a SQL statement. Must be called with ``await self.execute(...)`` """ with (await self.application.db.cursor()) as cur: await cur.execute(stmt, args)
[ "async", "def", "execute", "(", "self", ",", "stmt", ",", "*", "args", ")", ":", "with", "(", "await", "self", ".", "application", ".", "db", ".", "cursor", "(", ")", ")", "as", "cur", ":", "await", "cur", ".", "execute", "(", "stmt", ",", "args"...
Execute a SQL statement. Must be called with ``await self.execute(...)``
[ "Execute", "a", "SQL", "statement", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/demos/blog/blog.py#L91-L97
train
tornadoweb/tornado
demos/blog/blog.py
BaseHandler.query
async def query(self, stmt, *args): """Query for a list of results. Typical usage:: results = await self.query(...) Or:: for row in await self.query(...) """ with (await self.application.db.cursor()) as cur: await cur.execute(stmt, args) ...
python
async def query(self, stmt, *args): """Query for a list of results. Typical usage:: results = await self.query(...) Or:: for row in await self.query(...) """ with (await self.application.db.cursor()) as cur: await cur.execute(stmt, args) ...
[ "async", "def", "query", "(", "self", ",", "stmt", ",", "*", "args", ")", ":", "with", "(", "await", "self", ".", "application", ".", "db", ".", "cursor", "(", ")", ")", "as", "cur", ":", "await", "cur", ".", "execute", "(", "stmt", ",", "args", ...
Query for a list of results. Typical usage:: results = await self.query(...) Or:: for row in await self.query(...)
[ "Query", "for", "a", "list", "of", "results", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/demos/blog/blog.py#L99-L112
train
tornadoweb/tornado
demos/blog/blog.py
BaseHandler.queryone
async def queryone(self, stmt, *args): """Query for exactly one result. Raises NoResultError if there are no results, or ValueError if there are more than one. """ results = await self.query(stmt, *args) if len(results) == 0: raise NoResultError() eli...
python
async def queryone(self, stmt, *args): """Query for exactly one result. Raises NoResultError if there are no results, or ValueError if there are more than one. """ results = await self.query(stmt, *args) if len(results) == 0: raise NoResultError() eli...
[ "async", "def", "queryone", "(", "self", ",", "stmt", ",", "*", "args", ")", ":", "results", "=", "await", "self", ".", "query", "(", "stmt", ",", "*", "args", ")", "if", "len", "(", "results", ")", "==", "0", ":", "raise", "NoResultError", "(", ...
Query for exactly one result. Raises NoResultError if there are no results, or ValueError if there are more than one.
[ "Query", "for", "exactly", "one", "result", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/demos/blog/blog.py#L114-L125
train
tornadoweb/tornado
tornado/tcpserver.py
TCPServer.listen
def listen(self, port: int, address: str = "") -> None: """Starts accepting connections on the given port. This method may be called more than once to listen on multiple ports. `listen` takes effect immediately; it is not necessary to call `TCPServer.start` afterwards. It is, however, ...
python
def listen(self, port: int, address: str = "") -> None: """Starts accepting connections on the given port. This method may be called more than once to listen on multiple ports. `listen` takes effect immediately; it is not necessary to call `TCPServer.start` afterwards. It is, however, ...
[ "def", "listen", "(", "self", ",", "port", ":", "int", ",", "address", ":", "str", "=", "\"\"", ")", "->", "None", ":", "sockets", "=", "bind_sockets", "(", "port", ",", "address", "=", "address", ")", "self", ".", "add_sockets", "(", "sockets", ")" ...
Starts accepting connections on the given port. This method may be called more than once to listen on multiple ports. `listen` takes effect immediately; it is not necessary to call `TCPServer.start` afterwards. It is, however, necessary to start the `.IOLoop`.
[ "Starts", "accepting", "connections", "on", "the", "given", "port", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpserver.py#L143-L152
train
tornadoweb/tornado
tornado/tcpserver.py
TCPServer.add_sockets
def add_sockets(self, sockets: Iterable[socket.socket]) -> None: """Makes this server start accepting connections on the given sockets. The ``sockets`` parameter is a list of socket objects such as those returned by `~tornado.netutil.bind_sockets`. `add_sockets` is typically used in com...
python
def add_sockets(self, sockets: Iterable[socket.socket]) -> None: """Makes this server start accepting connections on the given sockets. The ``sockets`` parameter is a list of socket objects such as those returned by `~tornado.netutil.bind_sockets`. `add_sockets` is typically used in com...
[ "def", "add_sockets", "(", "self", ",", "sockets", ":", "Iterable", "[", "socket", ".", "socket", "]", ")", "->", "None", ":", "for", "sock", "in", "sockets", ":", "self", ".", "_sockets", "[", "sock", ".", "fileno", "(", ")", "]", "=", "sock", "se...
Makes this server start accepting connections on the given sockets. The ``sockets`` parameter is a list of socket objects such as those returned by `~tornado.netutil.bind_sockets`. `add_sockets` is typically used in combination with that method and `tornado.process.fork_processes` to pr...
[ "Makes", "this", "server", "start", "accepting", "connections", "on", "the", "given", "sockets", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpserver.py#L154-L167
train
tornadoweb/tornado
tornado/tcpserver.py
TCPServer.bind
def bind( self, port: int, address: str = None, family: socket.AddressFamily = socket.AF_UNSPEC, backlog: int = 128, reuse_port: bool = False, ) -> None: """Binds this server to the given port on the given address. To start the server, call `start`. I...
python
def bind( self, port: int, address: str = None, family: socket.AddressFamily = socket.AF_UNSPEC, backlog: int = 128, reuse_port: bool = False, ) -> None: """Binds this server to the given port on the given address. To start the server, call `start`. I...
[ "def", "bind", "(", "self", ",", "port", ":", "int", ",", "address", ":", "str", "=", "None", ",", "family", ":", "socket", ".", "AddressFamily", "=", "socket", ".", "AF_UNSPEC", ",", "backlog", ":", "int", "=", "128", ",", "reuse_port", ":", "bool",...
Binds this server to the given port on the given address. To start the server, call `start`. If you want to run this server in a single process, you can call `listen` as a shortcut to the sequence of `bind` and `start` calls. Address may be either an IP address or hostname. If it's a ...
[ "Binds", "this", "server", "to", "the", "given", "port", "on", "the", "given", "address", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpserver.py#L173-L210
train
tornadoweb/tornado
tornado/tcpserver.py
TCPServer.start
def start(self, num_processes: Optional[int] = 1, max_restarts: int = None) -> None: """Starts this server in the `.IOLoop`. By default, we run the server in this process and do not fork any additional child process. If num_processes is ``None`` or <= 0, we detect the number of cores ...
python
def start(self, num_processes: Optional[int] = 1, max_restarts: int = None) -> None: """Starts this server in the `.IOLoop`. By default, we run the server in this process and do not fork any additional child process. If num_processes is ``None`` or <= 0, we detect the number of cores ...
[ "def", "start", "(", "self", ",", "num_processes", ":", "Optional", "[", "int", "]", "=", "1", ",", "max_restarts", ":", "int", "=", "None", ")", "->", "None", ":", "assert", "not", "self", ".", "_started", "self", ".", "_started", "=", "True", "if",...
Starts this server in the `.IOLoop`. By default, we run the server in this process and do not fork any additional child process. If num_processes is ``None`` or <= 0, we detect the number of cores available on this machine and fork that number of child processes. If num_process...
[ "Starts", "this", "server", "in", "the", ".", "IOLoop", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpserver.py#L212-L246
train
tornadoweb/tornado
tornado/tcpserver.py
TCPServer.stop
def stop(self) -> None: """Stops listening for new connections. Requests currently in progress may still continue after the server is stopped. """ if self._stopped: return self._stopped = True for fd, sock in self._sockets.items(): assert ...
python
def stop(self) -> None: """Stops listening for new connections. Requests currently in progress may still continue after the server is stopped. """ if self._stopped: return self._stopped = True for fd, sock in self._sockets.items(): assert ...
[ "def", "stop", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_stopped", ":", "return", "self", ".", "_stopped", "=", "True", "for", "fd", ",", "sock", "in", "self", ".", "_sockets", ".", "items", "(", ")", ":", "assert", "sock", ".", "...
Stops listening for new connections. Requests currently in progress may still continue after the server is stopped.
[ "Stops", "listening", "for", "new", "connections", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpserver.py#L248-L261
train
tornadoweb/tornado
tornado/queues.py
Queue.put
def put( self, item: _T, timeout: Union[float, datetime.timedelta] = None ) -> "Future[None]": """Put an item into the queue, perhaps waiting until there is room. Returns a Future, which raises `tornado.util.TimeoutError` after a timeout. ``timeout`` may be a number denotin...
python
def put( self, item: _T, timeout: Union[float, datetime.timedelta] = None ) -> "Future[None]": """Put an item into the queue, perhaps waiting until there is room. Returns a Future, which raises `tornado.util.TimeoutError` after a timeout. ``timeout`` may be a number denotin...
[ "def", "put", "(", "self", ",", "item", ":", "_T", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "\"Future[None]\"", ":", "future", "=", "Future", "(", ")", "# type: Future[None]", "try", ":...
Put an item into the queue, perhaps waiting until there is room. Returns a Future, which raises `tornado.util.TimeoutError` after a timeout. ``timeout`` may be a number denoting a time (on the same scale as `tornado.ioloop.IOLoop.time`, normally `time.time`), or a `datetime.tim...
[ "Put", "an", "item", "into", "the", "queue", "perhaps", "waiting", "until", "there", "is", "room", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/queues.py#L186-L207
train
tornadoweb/tornado
tornado/queues.py
Queue.put_nowait
def put_nowait(self, item: _T) -> None: """Put an item into the queue without blocking. If no free slot is immediately available, raise `QueueFull`. """ self._consume_expired() if self._getters: assert self.empty(), "queue non-empty, why are getters waiting?" ...
python
def put_nowait(self, item: _T) -> None: """Put an item into the queue without blocking. If no free slot is immediately available, raise `QueueFull`. """ self._consume_expired() if self._getters: assert self.empty(), "queue non-empty, why are getters waiting?" ...
[ "def", "put_nowait", "(", "self", ",", "item", ":", "_T", ")", "->", "None", ":", "self", ".", "_consume_expired", "(", ")", "if", "self", ".", "_getters", ":", "assert", "self", ".", "empty", "(", ")", ",", "\"queue non-empty, why are getters waiting?\"", ...
Put an item into the queue without blocking. If no free slot is immediately available, raise `QueueFull`.
[ "Put", "an", "item", "into", "the", "queue", "without", "blocking", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/queues.py#L209-L223
train
tornadoweb/tornado
tornado/queues.py
Queue.get
def get(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[_T]: """Remove and return an item from the queue. Returns an awaitable which resolves once an item is available, or raises `tornado.util.TimeoutError` after a timeout. ``timeout`` may be a number denoting a ti...
python
def get(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[_T]: """Remove and return an item from the queue. Returns an awaitable which resolves once an item is available, or raises `tornado.util.TimeoutError` after a timeout. ``timeout`` may be a number denoting a ti...
[ "def", "get", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "_T", "]", ":", "future", "=", "Future", "(", ")", "# type: Future[_T]", "try", ":", "future", "....
Remove and return an item from the queue. Returns an awaitable which resolves once an item is available, or raises `tornado.util.TimeoutError` after a timeout. ``timeout`` may be a number denoting a time (on the same scale as `tornado.ioloop.IOLoop.time`, normally `time.time`), or a ...
[ "Remove", "and", "return", "an", "item", "from", "the", "queue", "." ]
b8b481770bcdb333a69afde5cce7eaa449128326
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/queues.py#L225-L252
train