partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
_HTTPConnection._on_timeout
Timeout callback of _HTTPConnection instance. Raise a `HTTPTimeoutError` when a timeout occurs. :info string key: More detailed timeout information.
tornado/simple_httpclient.py
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: """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...
[ "Timeout", "callback", "of", "_HTTPConnection", "instance", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/simple_httpclient.py#L474-L486
[ "def", "_on_timeout", "(", "self", ",", "info", ":", "str", "=", "None", ")", "->", "None", ":", "self", ".", "_timeout", "=", "None", "error_message", "=", "\"Timeout {0}\"", ".", "format", "(", "info", ")", "if", "info", "else", "\"Timeout\"", "if", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
_oauth10a_signature
Calculates the HMAC-SHA1 OAuth 1.0a signature for the given request. See http://oauth.net/core/1.0a/#signing_process
tornado/auth.py
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[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...
[ "Calculates", "the", "HMAC", "-", "SHA1", "OAuth", "1", ".", "0a", "signature", "for", "the", "given", "request", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L1130-L1162
[ "def", "_oauth10a_signature", "(", "consumer_token", ":", "Dict", "[", "str", ",", "Any", "]", ",", "method", ":", "str", ",", "url", ":", "str", ",", "parameters", ":", "Dict", "[", "str", ",", "Any", "]", "=", "{", "}", ",", "token", ":", "Dict",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
OpenIdMixin.authenticate_redirect
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...
tornado/auth.py
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 ...
[ "Redirects", "to", "the", "authentication", "URL", "for", "this", "service", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L88-L114
[ "def", "authenticate_redirect", "(", "self", ",", "callback_uri", ":", "str", "=", "None", ",", "ax_attrs", ":", "List", "[", "str", "]", "=", "[", "\"name\"", ",", "\"email\"", ",", "\"language\"", ",", "\"username\"", "]", ",", ")", "->", "None", ":", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
OpenIdMixin.get_authenticated_user
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...
tornado/auth.py
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]: """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...
[ "Fetches", "the", "authenticated", "user", "data", "upon", "redirect", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L116-L146
[ "async", "def", "get_authenticated_user", "(", "self", ",", "http_client", ":", "httpclient", ".", "AsyncHTTPClient", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "handler", "=", "cast", "(", "RequestHandler", ",", "self", ")", "# Veri...
b8b481770bcdb333a69afde5cce7eaa449128326
train
OAuthMixin.authorize_redirect
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...
tornado/auth.py
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, ) -> None: """Redirects the user to obtain OAuth authorization for this service. The ``callback_uri`` may be omitted if ...
[ "Redirects", "the", "user", "to", "obtain", "OAuth", "authorization", "for", "this", "service", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L287-L334
[ "async", "def", "authorize_redirect", "(", "self", ",", "callback_uri", ":", "str", "=", "None", ",", "extra_params", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ",", "http_client", ":", "httpclient", ".", "AsyncHTTPClient", "=", "None", ",", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
OAuthMixin.get_authenticated_user
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 ...
tornado/auth.py
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]: """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 ...
[ "Gets", "the", "OAuth", "authorized", "user", "and", "access", "token", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L336-L380
[ "async", "def", "get_authenticated_user", "(", "self", ",", "http_client", ":", "httpclient", ".", "AsyncHTTPClient", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "handler", "=", "cast", "(", "RequestHandler", ",", "self", ")", "reques...
b8b481770bcdb333a69afde5cce7eaa449128326
train
OAuthMixin._oauth_get_user_future
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...
tornado/auth.py
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]: """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 ...
[ "Subclasses", "must", "override", "this", "to", "get", "basic", "information", "about", "the", "user", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L468-L490
[ "async", "def", "_oauth_get_user_future", "(", "self", ",", "access_token", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "raise", "NotImplementedError", "(", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
OAuth2Mixin.authorize_redirect
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...
tornado/auth.py
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, scope: str = None, response_type: str = "code", ) -> None: """Redirects the user to obtain OAuth authorizatio...
[ "Redirects", "the", "user", "to", "obtain", "OAuth", "authorization", "for", "this", "service", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L548-L581
[ "def", "authorize_redirect", "(", "self", ",", "redirect_uri", ":", "str", "=", "None", ",", "client_id", ":", "str", "=", "None", ",", "client_secret", ":", "str", "=", "None", ",", "extra_params", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
OAuth2Mixin.oauth2_request
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, ...
tornado/auth.py
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 ...
[ "Fetches", "the", "given", "URL", "auth", "an", "OAuth2", "access", "token", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L605-L659
[ "async", "def", "oauth2_request", "(", "self", ",", "url", ":", "str", ",", "access_token", ":", "str", "=", "None", ",", "post_args", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ",", "*", "*", "args", ":", "Any", ")", "->", "Any", ":"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
TwitterMixin.authenticate_redirect
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...
tornado/auth.py
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: """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 ...
[ "Just", "like", "~OAuthMixin", ".", "authorize_redirect", "but", "auto", "-", "redirects", "if", "authorized", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L712-L732
[ "async", "def", "authenticate_redirect", "(", "self", ",", "callback_uri", ":", "str", "=", "None", ")", "->", "None", ":", "http", "=", "self", ".", "get_auth_http_client", "(", ")", "response", "=", "await", "http", ".", "fetch", "(", "self", ".", "_oa...
b8b481770bcdb333a69afde5cce7eaa449128326
train
TwitterMixin.twitter_request
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...
tornado/auth.py
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 ) -> Any: """Fetches the given API path, e.g., ``statuses/user_timeline/btaylor`` The path should not include the format or API version num...
[ "Fetches", "the", "given", "API", "path", "e", ".", "g", ".", "statuses", "/", "user_timeline", "/", "btaylor" ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L734-L807
[ "async", "def", "twitter_request", "(", "self", ",", "path", ":", "str", ",", "access_token", ":", "Dict", "[", "str", ",", "Any", "]", ",", "post_args", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ",", "*", "*", "args", ":", "Any", ")...
b8b481770bcdb333a69afde5cce7eaa449128326
train
GoogleOAuth2Mixin.get_authenticated_user
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...
tornado/auth.py
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]: """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...
[ "Handles", "the", "login", "for", "the", "Google", "user", "returning", "an", "access", "token", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L854-L916
[ "async", "def", "get_authenticated_user", "(", "self", ",", "redirect_uri", ":", "str", ",", "code", ":", "str", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "# noqa: E501", "handler", "=", "cast", "(", "RequestHandler", ",", "self", ")", "http",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
FacebookGraphMixin.get_authenticated_user
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 ...
tornado/auth.py
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, ) -> Optional[Dict[str, Any]]: """Handles the login for the Facebook user, returning a user object. Example ...
[ "Handles", "the", "login", "for", "the", "Facebook", "user", "returning", "a", "user", "object", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L927-L1032
[ "async", "def", "get_authenticated_user", "(", "self", ",", "redirect_uri", ":", "str", ",", "client_id", ":", "str", ",", "client_secret", ":", "str", ",", "code", ":", "str", ",", "extra_fields", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
FacebookGraphMixin.facebook_request
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 ...
tornado/auth.py
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 ...
[ "Fetches", "the", "given", "relative", "API", "path", "e", ".", "g", ".", "/", "btaylor", "/", "picture" ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L1034-L1094
[ "async", "def", "facebook_request", "(", "self", ",", "path", ":", "str", ",", "access_token", ":", "str", "=", "None", ",", "post_args", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ",", "*", "*", "args", ":", "Any", ")", "->", "Any", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Condition.wait
Wait for `.notify`. Returns a `.Future` that resolves ``True`` if the condition is notified, or ``False`` after a timeout.
tornado/locks.py
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]: """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...
[ "Wait", "for", ".", "notify", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L124-L142
[ "def", "wait", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "bool", "]", ":", "waiter", "=", "Future", "(", ")", "# type: Future[bool]", "self", ".", "_waiter...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Condition.notify
Wake ``n`` waiters.
tornado/locks.py
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: """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...
[ "Wake", "n", "waiters", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L144-L154
[ "def", "notify", "(", "self", ",", "n", ":", "int", "=", "1", ")", "->", "None", ":", "waiters", "=", "[", "]", "# Waiters we plan to run right now.", "while", "n", "and", "self", ".", "_waiters", ":", "waiter", "=", "self", ".", "_waiters", ".", "popl...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Event.set
Set the internal flag to ``True``. All waiters are awakened. Calling `.wait` once the flag is set will not block.
tornado/locks.py
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: """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(): ...
[ "Set", "the", "internal", "flag", "to", "True", ".", "All", "waiters", "are", "awakened", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L215-L225
[ "def", "set", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "_value", ":", "self", ".", "_value", "=", "True", "for", "fut", "in", "self", ".", "_waiters", ":", "if", "not", "fut", ".", "done", "(", ")", ":", "fut", ".", "set_r...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Event.wait
Block until the internal flag is true. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout.
tornado/locks.py
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]: """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: ...
[ "Block", "until", "the", "internal", "flag", "is", "true", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L234-L258
[ "def", "wait", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "None", "]", ":", "fut", "=", "Future", "(", ")", "# type: Future[None]", "if", "self", ".", "_v...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Semaphore.release
Increment the counter and wake one waiter.
tornado/locks.py
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: """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 ...
[ "Increment", "the", "counter", "and", "wake", "one", "waiter", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L397-L412
[ "def", "release", "(", "self", ")", "->", "None", ":", "self", ".", "_value", "+=", "1", "while", "self", ".", "_waiters", ":", "waiter", "=", "self", ".", "_waiters", ".", "popleft", "(", ")", "if", "not", "waiter", ".", "done", "(", ")", ":", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Semaphore.acquire
Decrement the counter. Returns an awaitable. Block if the counter is zero and wait for a `.release`. The awaitable raises `.TimeoutError` after the deadline.
tornado/locks.py
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]: """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", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L414-L440
[ "def", "acquire", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "_ReleasingContextManager", "]", ":", "waiter", "=", "Future", "(", ")", "# type: Future[_ReleasingCo...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BoundedSemaphore.release
Increment the counter and wake one waiter.
tornado/locks.py
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: """Increment the counter and wake one waiter.""" if self._value >= self._initial_value: raise ValueError("Semaphore released too many times") super(BoundedSemaphore, self).release()
[ "Increment", "the", "counter", "and", "wake", "one", "waiter", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L478-L482
[ "def", "release", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_value", ">=", "self", ".", "_initial_value", ":", "raise", "ValueError", "(", "\"Semaphore released too many times\"", ")", "super", "(", "BoundedSemaphore", ",", "self", ")", ".", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Lock.acquire
Attempt to lock. Returns an awaitable. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout.
tornado/locks.py
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]: """Attempt to lock. Returns an awaitable. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout. """ return self._block.acquire(time...
[ "Attempt", "to", "lock", ".", "Returns", "an", "awaitable", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L528-L536
[ "def", "acquire", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "_ReleasingContextManager", "]", ":", "return", "self", ".", "_block", ".", "acquire", "(", "time...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTP1Connection.read_response
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...
tornado/http1connection.py
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]: """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` ...
[ "Read", "a", "single", "HTTP", "response", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L165-L178
[ "def", "read_response", "(", "self", ",", "delegate", ":", "httputil", ".", "HTTPMessageDelegate", ")", "->", "Awaitable", "[", "bool", "]", ":", "if", "self", ".", "params", ".", "decompress", ":", "delegate", "=", "_GzipMessageDelegate", "(", "delegate", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTP1Connection._clear_callbacks
Clears the callback attributes. This allows the request handler to be garbage collected more quickly in CPython by breaking up reference cycles.
tornado/http1connection.py
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: """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...
[ "Clears", "the", "callback", "attributes", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L302-L312
[ "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]]...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTP1Connection.detach
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.
tornado/http1connection.py
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: """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...
[ "Take", "control", "of", "the", "underlying", "stream", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L347-L360
[ "def", "detach", "(", "self", ")", "->", "iostream", ".", "IOStream", ":", "self", ".", "_clear_callbacks", "(", ")", "stream", "=", "self", ".", "stream", "self", ".", "stream", "=", "None", "# type: ignore", "if", "not", "self", ".", "_finish_future", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTP1Connection.write_headers
Implements `.HTTPConnection.write_headers`.
tornado/http1connection.py
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, ) -> "Future[None]": """Implements `.HTTPConnection.write_headers`.""" lines = [] if self.is_client: ...
[ "Implements", ".", "HTTPConnection", ".", "write_headers", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L376-L465
[ "def", "write_headers", "(", "self", ",", "start_line", ":", "Union", "[", "httputil", ".", "RequestStartLine", ",", "httputil", ".", "ResponseStartLine", "]", ",", "headers", ":", "httputil", ".", "HTTPHeaders", ",", "chunk", ":", "bytes", "=", "None", ",",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTP1Connection.write
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.
tornado/http1connection.py
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]": """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...
[ "Implements", ".", "HTTPConnection", ".", "write", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L483-L499
[ "def", "write", "(", "self", ",", "chunk", ":", "bytes", ")", "->", "\"Future[None]\"", ":", "future", "=", "None", "if", "self", ".", "stream", ".", "closed", "(", ")", ":", "future", "=", "self", ".", "_write_future", "=", "Future", "(", ")", "self...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTP1Connection.finish
Implements `.HTTPConnection.finish`.
tornado/http1connection.py
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: """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...
[ "Implements", ".", "HTTPConnection", ".", "finish", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L501-L531
[ "def", "finish", "(", "self", ")", "->", "None", ":", "if", "(", "self", ".", "_expected_content_remaining", "is", "not", "None", "and", "self", ".", "_expected_content_remaining", "!=", "0", "and", "not", "self", ".", "stream", ".", "closed", "(", ")", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTP1ServerConnection.close
Closes the connection. Returns a `.Future` that resolves after the serving loop has exited.
tornado/http1connection.py
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: """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...
[ "Closes", "the", "connection", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L784-L796
[ "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...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTP1ServerConnection.start_serving
Starts serving requests on this connection. :arg delegate: a `.HTTPServerConnectionDelegate`
tornado/http1connection.py
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: """Starts serving requests on this connection. :arg delegate: a `.HTTPServerConnectionDelegate` """ assert isinstance(delegate, httputil.HTTPServerConnectionDelegate) fut = gen.convert_yielded(self...
[ "Starts", "serving", "requests", "on", "this", "connection", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L798-L807
[ "def", "start_serving", "(", "self", ",", "delegate", ":", "httputil", ".", "HTTPServerConnectionDelegate", ")", "->", "None", ":", "assert", "isinstance", "(", "delegate", ",", "httputil", ".", "HTTPServerConnectionDelegate", ")", "fut", "=", "gen", ".", "conve...
b8b481770bcdb333a69afde5cce7eaa449128326
train
websocket_connect
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...
tornado/websocket.py
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: float = None, on_message_callback: Callable[[Union[None, str, bytes]], None] = None, compression_options: Dict[str, Any] = None, ping_interval:...
[ "Client", "-", "side", "websocket", "support", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1586-L1663
[ "def", "websocket_connect", "(", "url", ":", "Union", "[", "str", ",", "httpclient", ".", "HTTPRequest", "]", ",", "callback", ":", "Callable", "[", "[", "\"Future[WebSocketClientConnection]\"", "]", ",", "None", "]", "=", "None", ",", "connect_timeout", ":", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketHandler.write_message
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...
tornado/websocket.py
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]": """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...
[ "Sends", "the", "given", "message", "to", "the", "client", "of", "this", "Web", "Socket", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L314-L342
[ "def", "write_message", "(", "self", ",", "message", ":", "Union", "[", "bytes", ",", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]", ",", "binary", ":", "bool", "=", "False", ")", "->", "\"Future[None]\"", ":", "if", "self", ".", "ws_connectio...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketHandler.ping
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...
tornado/websocket.py
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: """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. ...
[ "Send", "ping", "frame", "to", "the", "remote", "end", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L429-L448
[ "def", "ping", "(", "self", ",", "data", ":", "Union", "[", "str", ",", "bytes", "]", "=", "b\"\"", ")", "->", "None", ":", "data", "=", "utf8", "(", "data", ")", "if", "self", ".", "ws_connection", "is", "None", "or", "self", ".", "ws_connection",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketHandler.close
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...
tornado/websocket.py
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: """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...
[ "Closes", "this", "Web", "Socket", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L471-L489
[ "def", "close", "(", "self", ",", "code", ":", "int", "=", "None", ",", "reason", ":", "str", "=", "None", ")", "->", "None", ":", "if", "self", ".", "ws_connection", ":", "self", ".", "ws_connection", ".", "close", "(", "code", ",", "reason", ")",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketHandler.check_origin
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 ...
tornado/websocket.py
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: """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...
[ "Override", "to", "enable", "support", "for", "allowing", "alternate", "origins", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L491-L545
[ "def", "check_origin", "(", "self", ",", "origin", ":", "str", ")", "->", "bool", ":", "parsed_origin", "=", "urlparse", "(", "origin", ")", "origin", "=", "parsed_origin", ".", "netloc", "origin", "=", "origin", ".", "lower", "(", ")", "host", "=", "s...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketHandler.set_nodelay
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...
tornado/websocket.py
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: """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...
[ "Set", "the", "no", "-", "delay", "flag", "for", "this", "stream", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L547-L562
[ "def", "set_nodelay", "(", "self", ",", "value", ":", "bool", ")", "->", "None", ":", "assert", "self", ".", "ws_connection", "is", "not", "None", "self", ".", "ws_connection", ".", "set_nodelay", "(", "value", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketProtocol._run_callback
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.
tornado/websocket.py
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]]": """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", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L640-L659
[ "def", "_run_callback", "(", "self", ",", "callback", ":", "Callable", ",", "*", "args", ":", "Any", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "\"Optional[Future[Any]]\"", ":", "try", ":", "result", "=", "callback", "(", "*", "args", ",", "*", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketProtocol._abort
Instantly aborts the WebSocket connection by closing the socket
tornado/websocket.py
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: """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()
[ "Instantly", "aborts", "the", "WebSocket", "connection", "by", "closing", "the", "socket" ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L664-L670
[ "def", "_abort", "(", "self", ")", "->", "None", ":", "self", ".", "client_terminated", "=", "True", "self", ".", "server_terminated", "=", "True", "if", "self", ".", "stream", "is", "not", "None", ":", "self", ".", "stream", ".", "close", "(", ")", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketProtocol13._handle_websocket_headers
Verifies all invariant- and required headers If a header is missing or have an incorrect value ValueError will be raised
tornado/websocket.py
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: """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 ...
[ "Verifies", "all", "invariant", "-", "and", "required", "headers" ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L890-L898
[ "def", "_handle_websocket_headers", "(", "self", ",", "handler", ":", "WebSocketHandler", ")", "->", "None", ":", "fields", "=", "(", "\"Host\"", ",", "\"Sec-Websocket-Key\"", ",", "\"Sec-Websocket-Version\"", ")", "if", "not", "all", "(", "map", "(", "lambda", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketProtocol13.compute_accept_value
Computes the value for the Sec-WebSocket-Accept header, given the value for Sec-WebSocket-Key.
tornado/websocket.py
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: """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 ...
[ "Computes", "the", "value", "for", "the", "Sec", "-", "WebSocket", "-", "Accept", "header", "given", "the", "value", "for", "Sec", "-", "WebSocket", "-", "Key", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L901-L908
[ "def", "compute_accept_value", "(", "key", ":", "Union", "[", "str", ",", "bytes", "]", ")", "->", "str", ":", "sha1", "=", "hashlib", ".", "sha1", "(", ")", "sha1", ".", "update", "(", "utf8", "(", "key", ")", ")", "sha1", ".", "update", "(", "b...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketProtocol13._process_server_headers
Process the headers sent by the server to this client connection. 'key' is the websocket handshake challenge/response key.
tornado/websocket.py
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: """Process the headers sent by the server to this client connection. 'key' is the websocket handshake challenge/response key. """ assert headers["Upgrade"].lower() == "websock...
[ "Process", "the", "headers", "sent", "by", "the", "server", "to", "this", "client", "connection", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L974-L993
[ "def", "_process_server_headers", "(", "self", ",", "key", ":", "Union", "[", "str", ",", "bytes", "]", ",", "headers", ":", "httputil", ".", "HTTPHeaders", ")", "->", "None", ":", "assert", "headers", "[", "\"Upgrade\"", "]", ".", "lower", "(", ")", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketProtocol13._get_compressor_options
Converts a websocket agreed_parameters set to keyword arguments for our compressor objects.
tornado/websocket.py
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[str, Any]: """Converts a websocket agreed_parameters set to keyword arguments for our compressor objects. """ options...
[ "Converts", "a", "websocket", "agreed_parameters", "set", "to", "keyword", "arguments", "for", "our", "compressor", "objects", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L995-L1013
[ "def", "_get_compressor_options", "(", "self", ",", "side", ":", "str", ",", "agreed_parameters", ":", "Dict", "[", "str", ",", "Any", "]", ",", "compression_options", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ",", ")", "->", "Dict", "[", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketProtocol13.write_message
Sends the given message to the client of this Web Socket.
tornado/websocket.py
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]": """Sends the given message to the client of this Web Socket.""" if binary: opcode = 0x2 else: opcode = 0x1 message = tornado.escape.utf8(message) ass...
[ "Sends", "the", "given", "message", "to", "the", "client", "of", "this", "Web", "Socket", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1077-L1108
[ "def", "write_message", "(", "self", ",", "message", ":", "Union", "[", "str", ",", "bytes", "]", ",", "binary", ":", "bool", "=", "False", ")", "->", "\"Future[None]\"", ":", "if", "binary", ":", "opcode", "=", "0x2", "else", ":", "opcode", "=", "0x...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketProtocol13.write_ping
Send ping frame.
tornado/websocket.py
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: """Send ping frame.""" assert isinstance(data, bytes) self._write_frame(True, 0x9, data)
[ "Send", "ping", "frame", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1110-L1113
[ "def", "write_ping", "(", "self", ",", "data", ":", "bytes", ")", "->", "None", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "self", ".", "_write_frame", "(", "True", ",", "0x9", ",", "data", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketProtocol13._handle_message
Execute on_message, returning its Future if it is a coroutine.
tornado/websocket.py
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]]": """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: ...
[ "Execute", "on_message", "returning", "its", "Future", "if", "it", "is", "a", "coroutine", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1211-L1260
[ "def", "_handle_message", "(", "self", ",", "opcode", ":", "int", ",", "data", ":", "bytes", ")", "->", "\"Optional[Future[None]]\"", ":", "if", "self", ".", "client_terminated", ":", "return", "None", "if", "self", ".", "_frame_compressed", ":", "assert", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketProtocol13.close
Closes the WebSocket connection.
tornado/websocket.py
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: """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 ...
[ "Closes", "the", "WebSocket", "connection", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1262-L1289
[ "def", "close", "(", "self", ",", "code", ":", "int", "=", "None", ",", "reason", ":", "str", "=", "None", ")", "->", "None", ":", "if", "not", "self", ".", "server_terminated", ":", "if", "not", "self", ".", "stream", ".", "closed", "(", ")", ":...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketProtocol13.is_closing
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.
tornado/websocket.py
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 ``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...
[ "Return", "True", "if", "this", "connection", "is", "closing", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1291-L1298
[ "def", "is_closing", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "stream", ".", "closed", "(", ")", "or", "self", ".", "client_terminated", "or", "self", ".", "server_terminated" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketProtocol13.start_pinging
Start sending periodic pings to keep the connection alive
tornado/websocket.py
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: """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( ...
[ "Start", "sending", "periodic", "pings", "to", "keep", "the", "connection", "alive" ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1315-L1323
[ "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...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketProtocol13.periodic_ping
Send a ping to keep the websocket alive Called periodically if the websocket_ping_interval is set and non-zero.
tornado/websocket.py
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: """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 ...
[ "Send", "a", "ping", "to", "keep", "the", "websocket", "alive" ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1325-L1350
[ "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...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketClientConnection.close
Closes the websocket connection. ``code`` and ``reason`` are documented under `WebSocketHandler.close`. .. versionadded:: 3.2 .. versionchanged:: 4.0 Added the ``code`` and ``reason`` arguments.
tornado/websocket.py
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: """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", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1423-L1437
[ "def", "close", "(", "self", ",", "code", ":", "int", "=", "None", ",", "reason", ":", "str", "=", "None", ")", "->", "None", ":", "if", "self", ".", "protocol", "is", "not", "None", ":", "self", ".", "protocol", ".", "close", "(", "code", ",", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketClientConnection.write_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`...
tornado/websocket.py
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]": """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...
[ "Sends", "a", "message", "to", "the", "WebSocket", "server", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1494-L1506
[ "def", "write_message", "(", "self", ",", "message", ":", "Union", "[", "str", ",", "bytes", "]", ",", "binary", ":", "bool", "=", "False", ")", "->", "\"Future[None]\"", ":", "return", "self", ".", "protocol", ".", "write_message", "(", "message", ",", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketClientConnection.read_message
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...
tornado/websocket.py
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]]: """Reads a message from the WebSocket server. If on_message_callback was specified at WebSocket initialization, this function will never return messa...
[ "Reads", "a", "message", "from", "the", "WebSocket", "server", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1508-L1525
[ "def", "read_message", "(", "self", ",", "callback", ":", "Callable", "[", "[", "\"Future[Union[None, str, bytes]]\"", "]", ",", "None", "]", "=", "None", ")", "->", "Awaitable", "[", "Union", "[", "None", ",", "str", ",", "bytes", "]", "]", ":", "awaita...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WebSocketClientConnection.ping
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 ...
tornado/websocket.py
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: """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...
[ "Send", "ping", "frame", "to", "the", "remote", "end", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/websocket.py#L1539-L1556
[ "def", "ping", "(", "self", ",", "data", ":", "bytes", "=", "b\"\"", ")", "->", "None", ":", "data", "=", "utf8", "(", "data", ")", "if", "self", ".", "protocol", "is", "None", ":", "raise", "WebSocketClosedError", "(", ")", "self", ".", "protocol", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
define
Defines an option in the global namespace. See `OptionParser.define`.
tornado/options.py
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, group: str = None, callback: Callable[[Any], None] = None, ) -> None: """Defines an option in the global namespace. See `OptionParser.define`. """ ...
[ "Defines", "an", "option", "in", "the", "global", "namespace", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L667-L690
[ "def", "define", "(", "name", ":", "str", ",", "default", ":", "Any", "=", "None", ",", "type", ":", "type", "=", "None", ",", "help", ":", "str", "=", "None", ",", "metavar", ":", "str", "=", "None", ",", "multiple", ":", "bool", "=", "False", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
parse_command_line
Parses global options from the command line. See `OptionParser.parse_command_line`.
tornado/options.py
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]: """Parses global options from the command line. See `OptionParser.parse_command_line`. """ return options.parse_command_line(args, final=final)
[ "Parses", "global", "options", "from", "the", "command", "line", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L693-L698
[ "def", "parse_command_line", "(", "args", ":", "List", "[", "str", "]", "=", "None", ",", "final", ":", "bool", "=", "True", ")", "->", "List", "[", "str", "]", ":", "return", "options", ".", "parse_command_line", "(", "args", ",", "final", "=", "fin...
b8b481770bcdb333a69afde5cce7eaa449128326
train
parse_config_file
Parses global options from a config file. See `OptionParser.parse_config_file`.
tornado/options.py
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: """Parses global options from a config file. See `OptionParser.parse_config_file`. """ return options.parse_config_file(path, final=final)
[ "Parses", "global", "options", "from", "a", "config", "file", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L701-L706
[ "def", "parse_config_file", "(", "path", ":", "str", ",", "final", ":", "bool", "=", "True", ")", "->", "None", ":", "return", "options", ".", "parse_config_file", "(", "path", ",", "final", "=", "final", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
OptionParser.items
An iterable of (name, value) pairs. .. versionadded:: 3.1
tornado/options.py
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]]: """An iterable of (name, value) pairs. .. versionadded:: 3.1 """ return [(opt.name, opt.value()) for name, opt in self._options.items()]
[ "An", "iterable", "of", "(", "name", "value", ")", "pairs", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L166-L171
[ "def", "items", "(", "self", ")", "->", "Iterable", "[", "Tuple", "[", "str", ",", "Any", "]", "]", ":", "return", "[", "(", "opt", ".", "name", ",", "opt", ".", "value", "(", ")", ")", "for", "name", ",", "opt", "in", "self", ".", "_options", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
OptionParser.groups
The set of option-groups created by ``define``. .. versionadded:: 3.1
tornado/options.py
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]: """The set of option-groups created by ``define``. .. versionadded:: 3.1 """ return set(opt.group_name for opt in self._options.values())
[ "The", "set", "of", "option", "-", "groups", "created", "by", "define", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L173-L178
[ "def", "groups", "(", "self", ")", "->", "Set", "[", "str", "]", ":", "return", "set", "(", "opt", ".", "group_name", "for", "opt", "in", "self", ".", "_options", ".", "values", "(", ")", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
OptionParser.group_dict
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...
tornado/options.py
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]: """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...
[ "The", "names", "and", "values", "of", "options", "in", "a", "group", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L180-L201
[ "def", "group_dict", "(", "self", ",", "group", ":", "str", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "dict", "(", "(", "opt", ".", "name", ",", "opt", ".", "value", "(", ")", ")", "for", "name", ",", "opt", "in", "self", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
OptionParser.as_dict
The names and values of all options. .. versionadded:: 3.1
tornado/options.py
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]: """The names and values of all options. .. versionadded:: 3.1 """ return dict((opt.name, opt.value()) for name, opt in self._options.items())
[ "The", "names", "and", "values", "of", "all", "options", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L203-L208
[ "def", "as_dict", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "dict", "(", "(", "opt", ".", "name", ",", "opt", ".", "value", "(", ")", ")", "for", "name", ",", "opt", "in", "self", ".", "_options", ".", "items",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
OptionParser.define
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 ...
tornado/options.py
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 = False, group: str = None, callback: Callable[[Any], None] = None, ) -> None: """Defines a new command line opti...
[ "Defines", "a", "new", "command", "line", "option", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L210-L295
[ "def", "define", "(", "self", ",", "name", ":", "str", ",", "default", ":", "Any", "=", "None", ",", "type", ":", "type", "=", "None", ",", "help", ":", "str", "=", "None", ",", "metavar", ":", "str", "=", "None", ",", "multiple", ":", "bool", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
OptionParser.parse_command_line
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...
tornado/options.py
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]: """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...
[ "Parses", "all", "options", "given", "on", "the", "command", "line", "(", "defaults", "to", "sys", ".", "argv", ")", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L297-L349
[ "def", "parse_command_line", "(", "self", ",", "args", ":", "List", "[", "str", "]", "=", "None", ",", "final", ":", "bool", "=", "True", ")", "->", "List", "[", "str", "]", ":", "if", "args", "is", "None", ":", "args", "=", "sys", ".", "argv", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
OptionParser.parse_config_file
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 ...
tornado/options.py
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: """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...
[ "Parses", "and", "loads", "the", "config", "file", "at", "the", "given", "path", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L351-L418
[ "def", "parse_config_file", "(", "self", ",", "path", ":", "str", ",", "final", ":", "bool", "=", "True", ")", "->", "None", ":", "config", "=", "{", "\"__file__\"", ":", "os", ".", "path", ".", "abspath", "(", "path", ")", "}", "with", "open", "("...
b8b481770bcdb333a69afde5cce7eaa449128326
train
OptionParser.print_help
Prints all the command line options to stderr (or another file).
tornado/options.py
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: """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...
[ "Prints", "all", "the", "command", "line", "options", "to", "stderr", "(", "or", "another", "file", ")", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/options.py#L420-L448
[ "def", "print_help", "(", "self", ",", "file", ":", "TextIO", "=", "None", ")", "->", "None", ":", "if", "file", "is", "None", ":", "file", "=", "sys", ".", "stderr", "print", "(", "\"Usage: %s [OPTIONS]\"", "%", "sys", ".", "argv", "[", "0", "]", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseHandler.row_to_obj
Convert a SQL row to an object supporting dict and attribute access.
demos/blog/blog.py
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): """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
[ "Convert", "a", "SQL", "row", "to", "an", "object", "supporting", "dict", "and", "attribute", "access", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/demos/blog/blog.py#L84-L89
[ "def", "row_to_obj", "(", "self", ",", "row", ",", "cur", ")", ":", "obj", "=", "tornado", ".", "util", ".", "ObjectDict", "(", ")", "for", "val", ",", "desc", "in", "zip", "(", "row", ",", "cur", ".", "description", ")", ":", "obj", "[", "desc",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseHandler.execute
Execute a SQL statement. Must be called with ``await self.execute(...)``
demos/blog/blog.py
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): """Execute a SQL statement. Must be called with ``await self.execute(...)`` """ with (await self.application.db.cursor()) as cur: await cur.execute(stmt, args)
[ "Execute", "a", "SQL", "statement", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/demos/blog/blog.py#L91-L97
[ "async", "def", "execute", "(", "self", ",", "stmt", ",", "*", "args", ")", ":", "with", "(", "await", "self", ".", "application", ".", "db", ".", "cursor", "(", ")", ")", "as", "cur", ":", "await", "cur", ".", "execute", "(", "stmt", ",", "args"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseHandler.query
Query for a list of results. Typical usage:: results = await self.query(...) Or:: for row in await self.query(...)
demos/blog/blog.py
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): """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) ...
[ "Query", "for", "a", "list", "of", "results", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/demos/blog/blog.py#L99-L112
[ "async", "def", "query", "(", "self", ",", "stmt", ",", "*", "args", ")", ":", "with", "(", "await", "self", ".", "application", ".", "db", ".", "cursor", "(", ")", ")", "as", "cur", ":", "await", "cur", ".", "execute", "(", "stmt", ",", "args", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseHandler.queryone
Query for exactly one result. Raises NoResultError if there are no results, or ValueError if there are more than one.
demos/blog/blog.py
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): """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...
[ "Query", "for", "exactly", "one", "result", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/demos/blog/blog.py#L114-L125
[ "async", "def", "queryone", "(", "self", ",", "stmt", ",", "*", "args", ")", ":", "results", "=", "await", "self", ".", "query", "(", "stmt", ",", "*", "args", ")", "if", "len", "(", "results", ")", "==", "0", ":", "raise", "NoResultError", "(", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
TCPServer.listen
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`.
tornado/tcpserver.py
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: """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, ...
[ "Starts", "accepting", "connections", "on", "the", "given", "port", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpserver.py#L143-L152
[ "def", "listen", "(", "self", ",", "port", ":", "int", ",", "address", ":", "str", "=", "\"\"", ")", "->", "None", ":", "sockets", "=", "bind_sockets", "(", "port", ",", "address", "=", "address", ")", "self", ".", "add_sockets", "(", "sockets", ")" ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
TCPServer.add_sockets
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...
tornado/tcpserver.py
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: """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...
[ "Makes", "this", "server", "start", "accepting", "connections", "on", "the", "given", "sockets", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpserver.py#L154-L167
[ "def", "add_sockets", "(", "self", ",", "sockets", ":", "Iterable", "[", "socket", ".", "socket", "]", ")", "->", "None", ":", "for", "sock", "in", "sockets", ":", "self", ".", "_sockets", "[", "sock", ".", "fileno", "(", ")", "]", "=", "sock", "se...
b8b481770bcdb333a69afde5cce7eaa449128326
train
TCPServer.bind
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 ...
tornado/tcpserver.py
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 = False, ) -> None: """Binds this server to the given port on the given address. To start the server, call `start`. I...
[ "Binds", "this", "server", "to", "the", "given", "port", "on", "the", "given", "address", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpserver.py#L173-L210
[ "def", "bind", "(", "self", ",", "port", ":", "int", ",", "address", ":", "str", "=", "None", ",", "family", ":", "socket", ".", "AddressFamily", "=", "socket", ".", "AF_UNSPEC", ",", "backlog", ":", "int", "=", "128", ",", "reuse_port", ":", "bool",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
TCPServer.start
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...
tornado/tcpserver.py
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: """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 ...
[ "Starts", "this", "server", "in", "the", ".", "IOLoop", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpserver.py#L212-L246
[ "def", "start", "(", "self", ",", "num_processes", ":", "Optional", "[", "int", "]", "=", "1", ",", "max_restarts", ":", "int", "=", "None", ")", "->", "None", ":", "assert", "not", "self", ".", "_started", "self", ".", "_started", "=", "True", "if",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
TCPServer.stop
Stops listening for new connections. Requests currently in progress may still continue after the server is stopped.
tornado/tcpserver.py
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: """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 ...
[ "Stops", "listening", "for", "new", "connections", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpserver.py#L248-L261
[ "def", "stop", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_stopped", ":", "return", "self", ".", "_stopped", "=", "True", "for", "fd", ",", "sock", "in", "self", ".", "_sockets", ".", "items", "(", ")", ":", "assert", "sock", ".", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Queue.put
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...
tornado/queues.py
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]": """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...
[ "Put", "an", "item", "into", "the", "queue", "perhaps", "waiting", "until", "there", "is", "room", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/queues.py#L186-L207
[ "def", "put", "(", "self", ",", "item", ":", "_T", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "\"Future[None]\"", ":", "future", "=", "Future", "(", ")", "# type: Future[None]", "try", ":...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Queue.put_nowait
Put an item into the queue without blocking. If no free slot is immediately available, raise `QueueFull`.
tornado/queues.py
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: """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?" ...
[ "Put", "an", "item", "into", "the", "queue", "without", "blocking", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/queues.py#L209-L223
[ "def", "put_nowait", "(", "self", ",", "item", ":", "_T", ")", "->", "None", ":", "self", ".", "_consume_expired", "(", ")", "if", "self", ".", "_getters", ":", "assert", "self", ".", "empty", "(", ")", ",", "\"queue non-empty, why are getters waiting?\"", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Queue.get
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 ...
tornado/queues.py
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]: """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...
[ "Remove", "and", "return", "an", "item", "from", "the", "queue", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/queues.py#L225-L252
[ "def", "get", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "_T", "]", ":", "future", "=", "Future", "(", ")", "# type: Future[_T]", "try", ":", "future", "....
b8b481770bcdb333a69afde5cce7eaa449128326
train
Queue.get_nowait
Remove and return an item from the queue without blocking. Return an item if one is immediately available, else raise `QueueEmpty`.
tornado/queues.py
def get_nowait(self) -> _T: """Remove and return an item from the queue without blocking. Return an item if one is immediately available, else raise `QueueEmpty`. """ self._consume_expired() if self._putters: assert self.full(), "queue not full, why are putte...
def get_nowait(self) -> _T: """Remove and return an item from the queue without blocking. Return an item if one is immediately available, else raise `QueueEmpty`. """ self._consume_expired() if self._putters: assert self.full(), "queue not full, why are putte...
[ "Remove", "and", "return", "an", "item", "from", "the", "queue", "without", "blocking", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/queues.py#L254-L270
[ "def", "get_nowait", "(", "self", ")", "->", "_T", ":", "self", ".", "_consume_expired", "(", ")", "if", "self", ".", "_putters", ":", "assert", "self", ".", "full", "(", ")", ",", "\"queue not full, why are putters waiting?\"", "item", ",", "putter", "=", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Queue.task_done
Indicate that a formerly enqueued task is complete. Used by queue consumers. For each `.get` used to fetch a task, a subsequent call to `.task_done` tells the queue that the processing on the task is complete. If a `.join` is blocking, it resumes when all items have been proces...
tornado/queues.py
def task_done(self) -> None: """Indicate that a formerly enqueued task is complete. Used by queue consumers. For each `.get` used to fetch a task, a subsequent call to `.task_done` tells the queue that the processing on the task is complete. If a `.join` is blocking, it resumes...
def task_done(self) -> None: """Indicate that a formerly enqueued task is complete. Used by queue consumers. For each `.get` used to fetch a task, a subsequent call to `.task_done` tells the queue that the processing on the task is complete. If a `.join` is blocking, it resumes...
[ "Indicate", "that", "a", "formerly", "enqueued", "task", "is", "complete", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/queues.py#L272-L288
[ "def", "task_done", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_unfinished_tasks", "<=", "0", ":", "raise", "ValueError", "(", "\"task_done() called too many times\"", ")", "self", ".", "_unfinished_tasks", "-=", "1", "if", "self", ".", "_unfinis...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Queue.join
Block until all items in the queue are processed. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout.
tornado/queues.py
def join(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[None]: """Block until all items in the queue are processed. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout. """ return self._finished.wait(timeout)
def join(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[None]: """Block until all items in the queue are processed. Returns an awaitable, which raises `tornado.util.TimeoutError` after a timeout. """ return self._finished.wait(timeout)
[ "Block", "until", "all", "items", "in", "the", "queue", "are", "processed", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/queues.py#L290-L296
[ "def", "join", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "None", "]", ":", "return", "self", ".", "_finished", ".", "wait", "(", "timeout", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
cpu_count
Returns the number of processors on this machine.
tornado/process.py
def cpu_count() -> int: """Returns the number of processors on this machine.""" if multiprocessing is None: return 1 try: return multiprocessing.cpu_count() except NotImplementedError: pass try: return os.sysconf("SC_NPROCESSORS_CONF") except (AttributeError, Valu...
def cpu_count() -> int: """Returns the number of processors on this machine.""" if multiprocessing is None: return 1 try: return multiprocessing.cpu_count() except NotImplementedError: pass try: return os.sysconf("SC_NPROCESSORS_CONF") except (AttributeError, Valu...
[ "Returns", "the", "number", "of", "processors", "on", "this", "machine", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L51-L64
[ "def", "cpu_count", "(", ")", "->", "int", ":", "if", "multiprocessing", "is", "None", ":", "return", "1", "try", ":", "return", "multiprocessing", ".", "cpu_count", "(", ")", "except", "NotImplementedError", ":", "pass", "try", ":", "return", "os", ".", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
fork_processes
Starts multiple worker processes. If ``num_processes`` is None or <= 0, we detect the number of cores available on this machine and fork that number of child processes. If ``num_processes`` is given and > 0, we fork that specific number of sub-processes. Since we use processes and not threads, the...
tornado/process.py
def fork_processes(num_processes: Optional[int], max_restarts: int = None) -> int: """Starts multiple worker processes. If ``num_processes`` is None or <= 0, we detect the number of cores available on this machine and fork that number of child processes. If ``num_processes`` is given and > 0, we fork t...
def fork_processes(num_processes: Optional[int], max_restarts: int = None) -> int: """Starts multiple worker processes. If ``num_processes`` is None or <= 0, we detect the number of cores available on this machine and fork that number of child processes. If ``num_processes`` is given and > 0, we fork t...
[ "Starts", "multiple", "worker", "processes", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L92-L185
[ "def", "fork_processes", "(", "num_processes", ":", "Optional", "[", "int", "]", ",", "max_restarts", ":", "int", "=", "None", ")", "->", "int", ":", "if", "max_restarts", "is", "None", ":", "max_restarts", "=", "100", "global", "_task_id", "assert", "_tas...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Subprocess.set_exit_callback
Runs ``callback`` when this process exits. The callback takes one argument, the return code of the process. This method uses a ``SIGCHLD`` handler, which is a global setting and may conflict if you have other libraries trying to handle the same signal. If you are using more than one `...
tornado/process.py
def set_exit_callback(self, callback: Callable[[int], None]) -> None: """Runs ``callback`` when this process exits. The callback takes one argument, the return code of the process. This method uses a ``SIGCHLD`` handler, which is a global setting and may conflict if you have other libr...
def set_exit_callback(self, callback: Callable[[int], None]) -> None: """Runs ``callback`` when this process exits. The callback takes one argument, the return code of the process. This method uses a ``SIGCHLD`` handler, which is a global setting and may conflict if you have other libr...
[ "Runs", "callback", "when", "this", "process", "exits", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L264-L284
[ "def", "set_exit_callback", "(", "self", ",", "callback", ":", "Callable", "[", "[", "int", "]", ",", "None", "]", ")", "->", "None", ":", "self", ".", "_exit_callback", "=", "callback", "Subprocess", ".", "initialize", "(", ")", "Subprocess", ".", "_wai...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Subprocess.wait_for_exit
Returns a `.Future` which resolves when the process exits. Usage:: ret = yield proc.wait_for_exit() This is a coroutine-friendly alternative to `set_exit_callback` (and a replacement for the blocking `subprocess.Popen.wait`). By default, raises `subprocess.CalledProcessEr...
tornado/process.py
def wait_for_exit(self, raise_error: bool = True) -> "Future[int]": """Returns a `.Future` which resolves when the process exits. Usage:: ret = yield proc.wait_for_exit() This is a coroutine-friendly alternative to `set_exit_callback` (and a replacement for the blocking `s...
def wait_for_exit(self, raise_error: bool = True) -> "Future[int]": """Returns a `.Future` which resolves when the process exits. Usage:: ret = yield proc.wait_for_exit() This is a coroutine-friendly alternative to `set_exit_callback` (and a replacement for the blocking `s...
[ "Returns", "a", ".", "Future", "which", "resolves", "when", "the", "process", "exits", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L286-L316
[ "def", "wait_for_exit", "(", "self", ",", "raise_error", ":", "bool", "=", "True", ")", "->", "\"Future[int]\"", ":", "future", "=", "Future", "(", ")", "# type: Future[int]", "def", "callback", "(", "ret", ":", "int", ")", "->", "None", ":", "if", "ret"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Subprocess.initialize
Initializes the ``SIGCHLD`` handler. The signal handler is run on an `.IOLoop` to avoid locking issues. Note that the `.IOLoop` used for signal handling need not be the same one used by individual Subprocess objects (as long as the ``IOLoops`` are each running in separate threads). ...
tornado/process.py
def initialize(cls) -> None: """Initializes the ``SIGCHLD`` handler. The signal handler is run on an `.IOLoop` to avoid locking issues. Note that the `.IOLoop` used for signal handling need not be the same one used by individual Subprocess objects (as long as the ``IOLoops`` are...
def initialize(cls) -> None: """Initializes the ``SIGCHLD`` handler. The signal handler is run on an `.IOLoop` to avoid locking issues. Note that the `.IOLoop` used for signal handling need not be the same one used by individual Subprocess objects (as long as the ``IOLoops`` are...
[ "Initializes", "the", "SIGCHLD", "handler", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L319-L340
[ "def", "initialize", "(", "cls", ")", "->", "None", ":", "if", "cls", ".", "_initialized", ":", "return", "io_loop", "=", "ioloop", ".", "IOLoop", ".", "current", "(", ")", "cls", ".", "_old_sigchld", "=", "signal", ".", "signal", "(", "signal", ".", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Subprocess.uninitialize
Removes the ``SIGCHLD`` handler.
tornado/process.py
def uninitialize(cls) -> None: """Removes the ``SIGCHLD`` handler.""" if not cls._initialized: return signal.signal(signal.SIGCHLD, cls._old_sigchld) cls._initialized = False
def uninitialize(cls) -> None: """Removes the ``SIGCHLD`` handler.""" if not cls._initialized: return signal.signal(signal.SIGCHLD, cls._old_sigchld) cls._initialized = False
[ "Removes", "the", "SIGCHLD", "handler", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/process.py#L343-L348
[ "def", "uninitialize", "(", "cls", ")", "->", "None", ":", "if", "not", "cls", ".", "_initialized", ":", "return", "signal", ".", "signal", "(", "signal", ".", "SIGCHLD", ",", "cls", ".", "_old_sigchld", ")", "cls", ".", "_initialized", "=", "False" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
CurlAsyncHTTPClient._handle_socket
Called by libcurl when it wants to change the file descriptors it cares about.
tornado/curl_httpclient.py
def _handle_socket(self, event: int, fd: int, multi: Any, data: bytes) -> None: """Called by libcurl when it wants to change the file descriptors it cares about. """ event_map = { pycurl.POLL_NONE: ioloop.IOLoop.NONE, pycurl.POLL_IN: ioloop.IOLoop.READ, ...
def _handle_socket(self, event: int, fd: int, multi: Any, data: bytes) -> None: """Called by libcurl when it wants to change the file descriptors it cares about. """ event_map = { pycurl.POLL_NONE: ioloop.IOLoop.NONE, pycurl.POLL_IN: ioloop.IOLoop.READ, ...
[ "Called", "by", "libcurl", "when", "it", "wants", "to", "change", "the", "file", "descriptors", "it", "cares", "about", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L104-L131
[ "def", "_handle_socket", "(", "self", ",", "event", ":", "int", ",", "fd", ":", "int", ",", "multi", ":", "Any", ",", "data", ":", "bytes", ")", "->", "None", ":", "event_map", "=", "{", "pycurl", ".", "POLL_NONE", ":", "ioloop", ".", "IOLoop", "."...
b8b481770bcdb333a69afde5cce7eaa449128326
train
CurlAsyncHTTPClient._set_timeout
Called by libcurl to schedule a timeout.
tornado/curl_httpclient.py
def _set_timeout(self, msecs: int) -> None: """Called by libcurl to schedule a timeout.""" if self._timeout is not None: self.io_loop.remove_timeout(self._timeout) self._timeout = self.io_loop.add_timeout( self.io_loop.time() + msecs / 1000.0, self._handle_timeout ...
def _set_timeout(self, msecs: int) -> None: """Called by libcurl to schedule a timeout.""" if self._timeout is not None: self.io_loop.remove_timeout(self._timeout) self._timeout = self.io_loop.add_timeout( self.io_loop.time() + msecs / 1000.0, self._handle_timeout ...
[ "Called", "by", "libcurl", "to", "schedule", "a", "timeout", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L133-L139
[ "def", "_set_timeout", "(", "self", ",", "msecs", ":", "int", ")", "->", "None", ":", "if", "self", ".", "_timeout", "is", "not", "None", ":", "self", ".", "io_loop", ".", "remove_timeout", "(", "self", ".", "_timeout", ")", "self", ".", "_timeout", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
CurlAsyncHTTPClient._handle_events
Called by IOLoop when there is activity on one of our file descriptors.
tornado/curl_httpclient.py
def _handle_events(self, fd: int, events: int) -> None: """Called by IOLoop when there is activity on one of our file descriptors. """ action = 0 if events & ioloop.IOLoop.READ: action |= pycurl.CSELECT_IN if events & ioloop.IOLoop.WRITE: action |=...
def _handle_events(self, fd: int, events: int) -> None: """Called by IOLoop when there is activity on one of our file descriptors. """ action = 0 if events & ioloop.IOLoop.READ: action |= pycurl.CSELECT_IN if events & ioloop.IOLoop.WRITE: action |=...
[ "Called", "by", "IOLoop", "when", "there", "is", "activity", "on", "one", "of", "our", "file", "descriptors", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L141-L157
[ "def", "_handle_events", "(", "self", ",", "fd", ":", "int", ",", "events", ":", "int", ")", "->", "None", ":", "action", "=", "0", "if", "events", "&", "ioloop", ".", "IOLoop", ".", "READ", ":", "action", "|=", "pycurl", ".", "CSELECT_IN", "if", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
CurlAsyncHTTPClient._handle_timeout
Called by IOLoop when the requested timeout has passed.
tornado/curl_httpclient.py
def _handle_timeout(self) -> None: """Called by IOLoop when the requested timeout has passed.""" self._timeout = None while True: try: ret, num_handles = self._multi.socket_action(pycurl.SOCKET_TIMEOUT, 0) except pycurl.error as e: ret = e....
def _handle_timeout(self) -> None: """Called by IOLoop when the requested timeout has passed.""" self._timeout = None while True: try: ret, num_handles = self._multi.socket_action(pycurl.SOCKET_TIMEOUT, 0) except pycurl.error as e: ret = e....
[ "Called", "by", "IOLoop", "when", "the", "requested", "timeout", "has", "passed", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L159-L186
[ "def", "_handle_timeout", "(", "self", ")", "->", "None", ":", "self", ".", "_timeout", "=", "None", "while", "True", ":", "try", ":", "ret", ",", "num_handles", "=", "self", ".", "_multi", ".", "socket_action", "(", "pycurl", ".", "SOCKET_TIMEOUT", ",",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
CurlAsyncHTTPClient._handle_force_timeout
Called by IOLoop periodically to ask libcurl to process any events it may have forgotten about.
tornado/curl_httpclient.py
def _handle_force_timeout(self) -> None: """Called by IOLoop periodically to ask libcurl to process any events it may have forgotten about. """ while True: try: ret, num_handles = self._multi.socket_all() except pycurl.error as e: r...
def _handle_force_timeout(self) -> None: """Called by IOLoop periodically to ask libcurl to process any events it may have forgotten about. """ while True: try: ret, num_handles = self._multi.socket_all() except pycurl.error as e: r...
[ "Called", "by", "IOLoop", "periodically", "to", "ask", "libcurl", "to", "process", "any", "events", "it", "may", "have", "forgotten", "about", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L188-L199
[ "def", "_handle_force_timeout", "(", "self", ")", "->", "None", ":", "while", "True", ":", "try", ":", "ret", ",", "num_handles", "=", "self", ".", "_multi", ".", "socket_all", "(", ")", "except", "pycurl", ".", "error", "as", "e", ":", "ret", "=", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
CurlAsyncHTTPClient._finish_pending_requests
Process any requests that were completed by the last call to multi.socket_action.
tornado/curl_httpclient.py
def _finish_pending_requests(self) -> None: """Process any requests that were completed by the last call to multi.socket_action. """ while True: num_q, ok_list, err_list = self._multi.info_read() for curl in ok_list: self._finish(curl) ...
def _finish_pending_requests(self) -> None: """Process any requests that were completed by the last call to multi.socket_action. """ while True: num_q, ok_list, err_list = self._multi.info_read() for curl in ok_list: self._finish(curl) ...
[ "Process", "any", "requests", "that", "were", "completed", "by", "the", "last", "call", "to", "multi", ".", "socket_action", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/curl_httpclient.py#L201-L213
[ "def", "_finish_pending_requests", "(", "self", ")", "->", "None", ":", "while", "True", ":", "num_q", ",", "ok_list", ",", "err_list", "=", "self", ".", "_multi", ".", "info_read", "(", ")", "for", "curl", "in", "ok_list", ":", "self", ".", "_finish", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
start
Starts the mock S3 server on the given port at the given path.
demos/s3server/s3server.py
def start(port, root_directory, bucket_depth): """Starts the mock S3 server on the given port at the given path.""" application = S3Application(root_directory, bucket_depth) http_server = httpserver.HTTPServer(application) http_server.listen(port) ioloop.IOLoop.current().start()
def start(port, root_directory, bucket_depth): """Starts the mock S3 server on the given port at the given path.""" application = S3Application(root_directory, bucket_depth) http_server = httpserver.HTTPServer(application) http_server.listen(port) ioloop.IOLoop.current().start()
[ "Starts", "the", "mock", "S3", "server", "on", "the", "given", "port", "at", "the", "given", "path", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/demos/s3server/s3server.py#L57-L62
[ "def", "start", "(", "port", ",", "root_directory", ",", "bucket_depth", ")", ":", "application", "=", "S3Application", "(", "root_directory", ",", "bucket_depth", ")", "http_server", "=", "httpserver", ".", "HTTPServer", "(", "application", ")", "http_server", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTPClient.close
Closes the HTTPClient, freeing any resources used.
tornado/httpclient.py
def close(self) -> None: """Closes the HTTPClient, freeing any resources used.""" if not self._closed: self._async_client.close() self._io_loop.close() self._closed = True
def close(self) -> None: """Closes the HTTPClient, freeing any resources used.""" if not self._closed: self._async_client.close() self._io_loop.close() self._closed = True
[ "Closes", "the", "HTTPClient", "freeing", "any", "resources", "used", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpclient.py#L113-L118
[ "def", "close", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "_closed", ":", "self", ".", "_async_client", ".", "close", "(", ")", "self", ".", "_io_loop", ".", "close", "(", ")", "self", ".", "_closed", "=", "True" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTPClient.fetch
Executes a request, returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. If it is a string, we construct an `HTTPRequest` using any additional kwargs: ``HTTPRequest(request, **kwargs)`` If an error occurs during the fetch, we raise an `HTTPErr...
tornado/httpclient.py
def fetch( self, request: Union["HTTPRequest", str], **kwargs: Any ) -> "HTTPResponse": """Executes a request, returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. If it is a string, we construct an `HTTPRequest` using any additional ...
def fetch( self, request: Union["HTTPRequest", str], **kwargs: Any ) -> "HTTPResponse": """Executes a request, returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. If it is a string, we construct an `HTTPRequest` using any additional ...
[ "Executes", "a", "request", "returning", "an", "HTTPResponse", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpclient.py#L120-L135
[ "def", "fetch", "(", "self", ",", "request", ":", "Union", "[", "\"HTTPRequest\"", ",", "str", "]", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "\"HTTPResponse\"", ":", "response", "=", "self", ".", "_io_loop", ".", "run_sync", "(", "functools", "....
b8b481770bcdb333a69afde5cce7eaa449128326
train
AsyncHTTPClient.close
Destroys this HTTP client, freeing any file descriptors used. This method is **not needed in normal use** due to the way that `AsyncHTTPClient` objects are transparently reused. ``close()`` is generally only necessary when either the `.IOLoop` is also being closed, or the ``force_instan...
tornado/httpclient.py
def close(self) -> None: """Destroys this HTTP client, freeing any file descriptors used. This method is **not needed in normal use** due to the way that `AsyncHTTPClient` objects are transparently reused. ``close()`` is generally only necessary when either the `.IOLoop` is also...
def close(self) -> None: """Destroys this HTTP client, freeing any file descriptors used. This method is **not needed in normal use** due to the way that `AsyncHTTPClient` objects are transparently reused. ``close()`` is generally only necessary when either the `.IOLoop` is also...
[ "Destroys", "this", "HTTP", "client", "freeing", "any", "file", "descriptors", "used", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpclient.py#L221-L245
[ "def", "close", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_closed", ":", "return", "self", ".", "_closed", "=", "True", "if", "self", ".", "_instance_cache", "is", "not", "None", ":", "cached_val", "=", "self", ".", "_instance_cache", "....
b8b481770bcdb333a69afde5cce7eaa449128326
train
AsyncHTTPClient.fetch
Executes a request, asynchronously returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. If it is a string, we construct an `HTTPRequest` using any additional kwargs: ``HTTPRequest(request, **kwargs)`` This method returns a `.Future` whose resu...
tornado/httpclient.py
def fetch( self, request: Union[str, "HTTPRequest"], raise_error: bool = True, **kwargs: Any ) -> Awaitable["HTTPResponse"]: """Executes a request, asynchronously returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. ...
def fetch( self, request: Union[str, "HTTPRequest"], raise_error: bool = True, **kwargs: Any ) -> Awaitable["HTTPResponse"]: """Executes a request, asynchronously returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. ...
[ "Executes", "a", "request", "asynchronously", "returning", "an", "HTTPResponse", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpclient.py#L247-L305
[ "def", "fetch", "(", "self", ",", "request", ":", "Union", "[", "str", ",", "\"HTTPRequest\"", "]", ",", "raise_error", ":", "bool", "=", "True", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "Awaitable", "[", "\"HTTPResponse\"", "]", ":", "if", "s...
b8b481770bcdb333a69afde5cce7eaa449128326
train
AsyncHTTPClient.configure
Configures the `AsyncHTTPClient` subclass to use. ``AsyncHTTPClient()`` actually creates an instance of a subclass. This method may be called with either a class object or the fully-qualified name of such a class (or ``None`` to use the default, ``SimpleAsyncHTTPClient``) If ad...
tornado/httpclient.py
def configure( cls, impl: "Union[None, str, Type[Configurable]]", **kwargs: Any ) -> None: """Configures the `AsyncHTTPClient` subclass to use. ``AsyncHTTPClient()`` actually creates an instance of a subclass. This method may be called with either a class object or the fully...
def configure( cls, impl: "Union[None, str, Type[Configurable]]", **kwargs: Any ) -> None: """Configures the `AsyncHTTPClient` subclass to use. ``AsyncHTTPClient()`` actually creates an instance of a subclass. This method may be called with either a class object or the fully...
[ "Configures", "the", "AsyncHTTPClient", "subclass", "to", "use", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpclient.py#L313-L334
[ "def", "configure", "(", "cls", ",", "impl", ":", "\"Union[None, str, Type[Configurable]]\"", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "super", "(", "AsyncHTTPClient", ",", "cls", ")", ".", "configure", "(", "impl", ",", "*", "*", "kw...
b8b481770bcdb333a69afde5cce7eaa449128326
train
BaseConnector._cleanup
Cleanup unused transports.
aiohttp/connector.py
def _cleanup(self) -> None: """Cleanup unused transports.""" if self._cleanup_handle: self._cleanup_handle.cancel() now = self._loop.time() timeout = self._keepalive_timeout if self._conns: connections = {} deadline = now - timeout ...
def _cleanup(self) -> None: """Cleanup unused transports.""" if self._cleanup_handle: self._cleanup_handle.cancel() now = self._loop.time() timeout = self._keepalive_timeout if self._conns: connections = {} deadline = now - timeout ...
[ "Cleanup", "unused", "transports", "." ]
aio-libs/aiohttp
python
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L327-L359
[ "def", "_cleanup", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_cleanup_handle", ":", "self", ".", "_cleanup_handle", ".", "cancel", "(", ")", "now", "=", "self", ".", "_loop", ".", "time", "(", ")", "timeout", "=", "self", ".", "_keepal...
9504fe2affaaff673fa4f3754c1c44221f8ba47d
train
BaseConnector._cleanup_closed
Double confirmation for transport close. Some broken ssl servers may leave socket open without proper close.
aiohttp/connector.py
def _cleanup_closed(self) -> None: """Double confirmation for transport close. Some broken ssl servers may leave socket open without proper close. """ if self._cleanup_closed_handle: self._cleanup_closed_handle.cancel() for transport in self._cleanup_closed_transport...
def _cleanup_closed(self) -> None: """Double confirmation for transport close. Some broken ssl servers may leave socket open without proper close. """ if self._cleanup_closed_handle: self._cleanup_closed_handle.cancel() for transport in self._cleanup_closed_transport...
[ "Double", "confirmation", "for", "transport", "close", ".", "Some", "broken", "ssl", "servers", "may", "leave", "socket", "open", "without", "proper", "close", "." ]
aio-libs/aiohttp
python
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L371-L387
[ "def", "_cleanup_closed", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_cleanup_closed_handle", ":", "self", ".", "_cleanup_closed_handle", ".", "cancel", "(", ")", "for", "transport", "in", "self", ".", "_cleanup_closed_transports", ":", "if", "tr...
9504fe2affaaff673fa4f3754c1c44221f8ba47d
train
BaseConnector._available_connections
Return number of available connections taking into account the limit, limit_per_host and the connection key. If it returns less than 1 means that there is no connections availables.
aiohttp/connector.py
def _available_connections(self, key: 'ConnectionKey') -> int: """ Return number of available connections taking into account the limit, limit_per_host and the connection key. If it returns less than 1 means that there is no connections availables. """ if self._...
def _available_connections(self, key: 'ConnectionKey') -> int: """ Return number of available connections taking into account the limit, limit_per_host and the connection key. If it returns less than 1 means that there is no connections availables. """ if self._...
[ "Return", "number", "of", "available", "connections", "taking", "into", "account", "the", "limit", "limit_per_host", "and", "the", "connection", "key", "." ]
aio-libs/aiohttp
python
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L439-L467
[ "def", "_available_connections", "(", "self", ",", "key", ":", "'ConnectionKey'", ")", "->", "int", ":", "if", "self", ".", "_limit", ":", "# total calc available connections", "available", "=", "self", ".", "_limit", "-", "len", "(", "self", ".", "_acquired",...
9504fe2affaaff673fa4f3754c1c44221f8ba47d