_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q227000 | KubeCluster.from_yaml | train | def from_yaml(cls, yaml_path, **kwargs):
""" Create cluster with worker pod spec defined by a YAML file
We can start a cluster with pods defined in an accompanying YAML file
like the following:
.. code-block:: yaml
kind: Pod
metadata:
labels:
... | python | {
"resource": ""
} |
q227001 | KubeCluster.pods | train | def pods(self):
""" A list of kubernetes pods corresponding to current workers
See Also
--------
KubeCluster.logs
"""
return self.core_api.list_namespaced_pod(
self.namespace,
label_selector=format_labels(self.pod_template.metadata.labels)
... | python | {
"resource": ""
} |
q227002 | KubeCluster.logs | train | def logs(self, pod=None):
""" Logs from a worker pod
You can get this pod object from the ``pods`` method.
If no pod is specified all pod logs will be returned. On large clusters
this could end up being rather large.
Parameters
----------
pod: kubernetes.client... | python | {
"resource": ""
} |
q227003 | KubeCluster.scale | train | def scale(self, n):
""" Scale cluster to n workers
Parameters
----------
n: int
Target number of workers
Example
-------
>>> cluster.scale(10) # scale cluster to ten workers
See Also
--------
KubeCluster.scale_up
Kub... | python | {
"resource": ""
} |
q227004 | KubeCluster.scale_up | train | def scale_up(self, n, pods=None, **kwargs):
"""
Make sure we have n dask-workers available for this cluster
Examples
--------
>>> cluster.scale_up(20) # ask for twenty workers
"""
maximum = dask.config.get('kubernetes.count.max')
if maximum is not None a... | python | {
"resource": ""
} |
q227005 | KubeCluster.scale_down | train | def scale_down(self, workers, pods=None):
""" Remove the pods for the requested list of workers
When scale_down is called by the _adapt async loop, the workers are
assumed to have been cleanly closed first and in-memory data has been
migrated to the remaining workers.
Note that... | python | {
"resource": ""
} |
q227006 | KubeCluster.close | train | def close(self, **kwargs):
""" Close this cluster """
self.scale_down(self.cluster.scheduler.workers)
return self.cluster.close(**kwargs) | python | {
"resource": ""
} |
q227007 | job_to_dict | train | def job_to_dict(job):
"""Converts a job to an OrderedDict."""
data = OrderedDict()
data['id'] = job.id
data['name'] = job.name
data['func'] = job.func_ref
data['args'] = job.args
data['kwargs'] = job.kwargs
data.update(trigger_to_dict(job.trigger))
if not job.pending:
data... | python | {
"resource": ""
} |
q227008 | pop_trigger | train | def pop_trigger(data):
"""Pops trigger and trigger args from a given dict."""
trigger_name = data.pop('trigger')
trigger_args = {}
if trigger_name == 'date':
trigger_arg_names = ('run_date', 'timezone')
elif trigger_name == 'interval':
trigger_arg_names = ('weeks', 'days', 'hours',... | python | {
"resource": ""
} |
q227009 | trigger_to_dict | train | def trigger_to_dict(trigger):
"""Converts a trigger to an OrderedDict."""
data = OrderedDict()
if isinstance(trigger, DateTrigger):
data['trigger'] = 'date'
data['run_date'] = trigger.run_date
elif isinstance(trigger, IntervalTrigger):
data['trigger'] = 'interval'
data[... | python | {
"resource": ""
} |
q227010 | fix_job_def | train | def fix_job_def(job_def):
"""
Replaces the datetime in string by datetime object.
"""
if six.PY2 and isinstance(job_def.get('func'), six.text_type):
# when a job comes from the endpoint, strings are unicode
# because that's how json package deserialize the bytes.
# we had a case ... | python | {
"resource": ""
} |
q227011 | APScheduler.init_app | train | def init_app(self, app):
"""Initialize the APScheduler with a Flask application instance."""
self.app = app
self.app.apscheduler = self
self._load_config()
self._load_jobs()
if self.api_enabled:
self._load_api() | python | {
"resource": ""
} |
q227012 | APScheduler.add_listener | train | def add_listener(self, callback, mask=EVENT_ALL):
"""
Add a listener for scheduler events.
When a matching event occurs, ``callback`` is executed with the event object as its
sole argument. If the ``mask`` parameter is not provided, the callback will receive events
of all types... | python | {
"resource": ""
} |
q227013 | APScheduler.add_job | train | def add_job(self, id, func, **kwargs):
"""
Add the given job to the job list and wakes up the scheduler if it's already running.
:param str id: explicit identifier for the job (for modifying it later)
:param func: callable (or a textual reference to one) to run at the given time
... | python | {
"resource": ""
} |
q227014 | APScheduler.delete_job | train | def delete_job(self, id, jobstore=None):
"""
DEPRECATED, use remove_job instead.
Remove a job, preventing it from being run any more.
:param str id: the identifier of the job
:param str jobstore: alias of the job store that contains the job
"""
warnings.warn('de... | python | {
"resource": ""
} |
q227015 | APScheduler.modify_job | train | def modify_job(self, id, jobstore=None, **changes):
"""
Modify the properties of a single job. Modifications are passed to this method as extra keyword arguments.
:param str id: the identifier of the job
:param str jobstore: alias of the job store that contains the job
"""
... | python | {
"resource": ""
} |
q227016 | APScheduler._load_config | train | def _load_config(self):
"""
Load the configuration from the Flask configuration.
"""
options = dict()
job_stores = self.app.config.get('SCHEDULER_JOBSTORES')
if job_stores:
options['jobstores'] = job_stores
executors = self.app.config.get('SCHEDULER_... | python | {
"resource": ""
} |
q227017 | APScheduler._load_jobs | train | def _load_jobs(self):
"""
Load the job definitions from the Flask configuration.
"""
jobs = self.app.config.get('SCHEDULER_JOBS')
if not jobs:
jobs = self.app.config.get('JOBS')
if jobs:
for job in jobs:
self.add_job(**job) | python | {
"resource": ""
} |
q227018 | APScheduler._load_api | train | def _load_api(self):
"""
Add the routes for the scheduler API.
"""
self._add_url_route('get_scheduler_info', '', api.get_scheduler_info, 'GET')
self._add_url_route('add_job', '/jobs', api.add_job, 'POST')
self._add_url_route('get_job', '/jobs/<job_id>', api.get_job, 'GET'... | python | {
"resource": ""
} |
q227019 | APScheduler._handle_authentication_error | train | def _handle_authentication_error(self):
"""
Return an authentication error.
"""
response = make_response('Access Denied')
response.headers['WWW-Authenticate'] = self.auth.get_authenticate_header()
response.status_code = 401
return response | python | {
"resource": ""
} |
q227020 | get_scheduler_info | train | def get_scheduler_info():
"""Gets the scheduler info."""
scheduler = current_app.apscheduler
d = OrderedDict([
('current_host', scheduler.host_name),
('allowed_hosts', scheduler.allowed_hosts),
('running', scheduler.running)
])
return jsonify(d) | python | {
"resource": ""
} |
q227021 | add_job | train | def add_job():
"""Adds a new job."""
data = request.get_json(force=True)
try:
job = current_app.apscheduler.add_job(**data)
return jsonify(job)
except ConflictingIdError:
return jsonify(dict(error_message='Job %s already exists.' % data.get('id')), status=409)
except Except... | python | {
"resource": ""
} |
q227022 | get_job | train | def get_job(job_id):
"""Gets a job."""
job = current_app.apscheduler.get_job(job_id)
if not job:
return jsonify(dict(error_message='Job %s not found' % job_id), status=404)
return jsonify(job) | python | {
"resource": ""
} |
q227023 | get_jobs | train | def get_jobs():
"""Gets all scheduled jobs."""
jobs = current_app.apscheduler.get_jobs()
job_states = []
for job in jobs:
job_states.append(job)
return jsonify(job_states) | python | {
"resource": ""
} |
q227024 | update_job | train | def update_job(job_id):
"""Updates a job."""
data = request.get_json(force=True)
try:
current_app.apscheduler.modify_job(job_id, **data)
job = current_app.apscheduler.get_job(job_id)
return jsonify(job)
except JobLookupError:
return jsonify(dict(error_message='Job %s no... | python | {
"resource": ""
} |
q227025 | resume_job | train | def resume_job(job_id):
"""Resumes a job."""
try:
current_app.apscheduler.resume_job(job_id)
job = current_app.apscheduler.get_job(job_id)
return jsonify(job)
except JobLookupError:
return jsonify(dict(error_message='Job %s not found' % job_id), status=404)
except Except... | python | {
"resource": ""
} |
q227026 | QuartGroup.get_command | train | def get_command(self, ctx: click.Context, name: str) -> click.Command:
"""Return the relevant command given the context and name.
.. warning::
This differs substaintially from Flask in that it allows
for the inbuilt commands to be overridden.
"""
info = ctx.ensu... | python | {
"resource": ""
} |
q227027 | render_template | train | async def render_template(template_name_or_list: Union[str, List[str]], **context: Any) -> str:
"""Render the template with the context given.
Arguments:
template_name_or_list: Template name to render of a list of
possible template names.
context: The variables to pass to the templa... | python | {
"resource": ""
} |
q227028 | render_template_string | train | async def render_template_string(source: str, **context: Any) -> str:
"""Render the template source with the context given.
Arguments:
source: The template source code.
context: The variables to pass to the template.
"""
await current_app.update_template_context(context)
template = ... | python | {
"resource": ""
} |
q227029 | DispatchingJinjaLoader.get_source | train | def get_source(
self, environment: Environment, template: str,
) -> Tuple[str, Optional[str], Callable]:
"""Returns the template source from the environment.
This considers the loaders on the :attr:`app` and blueprints.
"""
for loader in self._loaders():
try:... | python | {
"resource": ""
} |
q227030 | DispatchingJinjaLoader.list_templates | train | def list_templates(self) -> List[str]:
"""Returns a list of all avilable templates in environment.
This considers the loaders on the :attr:`app` and blueprints.
"""
result = set()
for loader in self._loaders():
for template in loader.list_templates():
... | python | {
"resource": ""
} |
q227031 | Blueprint.route | train | def route(
self,
path: str,
methods: Optional[List[str]]=None,
endpoint: Optional[str]=None,
defaults: Optional[dict]=None,
host: Optional[str]=None,
subdomain: Optional[str]=None,
*,
provide_automatic_options: O... | python | {
"resource": ""
} |
q227032 | Blueprint.websocket | train | def websocket(
self,
path: str,
endpoint: Optional[str]=None,
defaults: Optional[dict]=None,
host: Optional[str]=None,
subdomain: Optional[str]=None,
*,
strict_slashes: bool=True,
) -> Callable:
"""Add a websocke... | python | {
"resource": ""
} |
q227033 | Blueprint.add_websocket | train | def add_websocket(
self,
path: str,
endpoint: Optional[str]=None,
view_func: Optional[Callable]=None,
defaults: Optional[dict]=None,
host: Optional[str]=None,
subdomain: Optional[str]=None,
*,
strict_slashes: boo... | python | {
"resource": ""
} |
q227034 | Blueprint.endpoint | train | def endpoint(self, endpoint: str) -> Callable:
"""Add an endpoint to the blueprint.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.endpoint`. An example usage,
.. code-block:: python
blueprint = Blueprint(__name__)
... | python | {
"resource": ""
} |
q227035 | Blueprint.before_request | train | def before_request(self, func: Callable) -> Callable:
"""Add a before request function to the Blueprint.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.before_request`. It applies only to requests that
are routed to an endpoint in this blue... | python | {
"resource": ""
} |
q227036 | Blueprint.before_websocket | train | def before_websocket(self, func: Callable) -> Callable:
"""Add a before request websocket to the Blueprint.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.before_websocket`. It applies only to requests that
are routed to an endpoint in this... | python | {
"resource": ""
} |
q227037 | Blueprint.before_app_request | train | def before_app_request(self, func: Callable) -> Callable:
"""Add a before request function to the app.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.before_request`. It applies to all requests to the
app this blueprint is registered on. An... | python | {
"resource": ""
} |
q227038 | Blueprint.before_app_websocket | train | def before_app_websocket(self, func: Callable) -> Callable:
"""Add a before request websocket to the App.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.before_websocket`. It applies to all requests to the
app this blueprint is registered o... | python | {
"resource": ""
} |
q227039 | Blueprint.before_app_first_request | train | def before_app_first_request(self, func: Callable) -> Callable:
"""Add a before request first function to the app.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.before_first_request`. It is
triggered before the first request to the app thi... | python | {
"resource": ""
} |
q227040 | Blueprint.after_request | train | def after_request(self, func: Callable) -> Callable:
"""Add an after request function to the Blueprint.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.after_request`. It applies only to requests that
are routed to an endpoint in this bluepr... | python | {
"resource": ""
} |
q227041 | Blueprint.after_websocket | train | def after_websocket(self, func: Callable) -> Callable:
"""Add an after websocket function to the Blueprint.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.after_websocket`. It applies only to requests that
are routed to an endpoint in this ... | python | {
"resource": ""
} |
q227042 | Blueprint.after_app_request | train | def after_app_request(self, func: Callable) -> Callable:
"""Add a after request function to the app.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.after_request`. It applies to all requests to the
app this blueprint is registered on. An ex... | python | {
"resource": ""
} |
q227043 | Blueprint.after_app_websocket | train | def after_app_websocket(self, func: Callable) -> Callable:
"""Add an after websocket function to the App.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.after_websocket`. It applies to all requests to the
ppe this blueprint is registerd on.... | python | {
"resource": ""
} |
q227044 | Blueprint.teardown_request | train | def teardown_request(self, func: Callable) -> Callable:
"""Add a teardown request function to the Blueprint.
This is designed to be used as a decorator, and has the same arguments
as :meth:`~quart.Quart.teardown_request`. It applies only to requests that
are routed to an endpoint in thi... | python | {
"resource": ""
} |
q227045 | Blueprint.teardown_websocket | train | def teardown_websocket(self, func: Callable) -> Callable:
"""Add a teardown websocket function to the Blueprint.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.teardown_websocket`. It
applies only to requests that are routed to an endpoint ... | python | {
"resource": ""
} |
q227046 | Blueprint.teardown_app_request | train | def teardown_app_request(self, func: Callable) -> Callable:
"""Add a teardown request function to the app.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.teardown_request`. It applies
to all requests to the app this blueprint is registered ... | python | {
"resource": ""
} |
q227047 | Blueprint.errorhandler | train | def errorhandler(self, error: Union[Type[Exception], int]) -> Callable:
"""Add an error handler function to the Blueprint.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.errorhandler`. It applies
only to errors that originate in routes in t... | python | {
"resource": ""
} |
q227048 | Blueprint.app_errorhandler | train | def app_errorhandler(self, error: Union[Type[Exception], int]) -> Callable:
"""Add an error handler function to the App.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.errorhandler`. It applies
only to all errors. An example usage,
... | python | {
"resource": ""
} |
q227049 | Blueprint.register_error_handler | train | def register_error_handler(self, error: Union[Type[Exception], int], func: Callable) -> None:
"""Add an error handler function to the blueprint.
This is designed to be used on the blueprint directly, and
has the same arguments as
:meth:`~quart.Quart.register_error_handler`. An example u... | python | {
"resource": ""
} |
q227050 | Blueprint.context_processor | train | def context_processor(self, func: Callable) -> Callable:
"""Add a context processor function to this blueprint.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.context_processor`. This will
add context to all templates rendered in this bluep... | python | {
"resource": ""
} |
q227051 | Blueprint.app_context_processor | train | def app_context_processor(self, func: Callable) -> Callable:
"""Add a context processor function to the app.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.context_processor`. This will
add context to all templates rendered. An example usag... | python | {
"resource": ""
} |
q227052 | Blueprint.record_once | train | def record_once(self, func: DeferedSetupFunction) -> None:
"""Used to register a deferred action that happens only once."""
def wrapper(state: 'BlueprintSetupState') -> None:
if state.first_registration:
func(state)
self.record(update_wrapper(wrapper, func)) | python | {
"resource": ""
} |
q227053 | Blueprint.register | train | def register(
self,
app: 'Quart',
first_registration: bool,
*,
url_prefix: Optional[str]=None,
) -> None:
"""Register this blueprint on the app given."""
state = self.make_setup_state(app, first_registration, url_prefix=url_prefix)
... | python | {
"resource": ""
} |
q227054 | Blueprint.make_setup_state | train | def make_setup_state(
self,
app: 'Quart',
first_registration: bool,
*,
url_prefix: Optional[str]=None,
) -> 'BlueprintSetupState':
"""Return a blueprint setup state instance.
Arguments:
first_registration: True if this is the f... | python | {
"resource": ""
} |
q227055 | _WerkzeugMultidictMixin.to_dict | train | def to_dict(self, flat: bool=True) -> Dict[Any, Any]:
"""Convert the multidict to a plain dictionary.
Arguments:
flat: If True only return the a value for each key, if
False return all values as lists.
"""
if flat:
return {key: value for key, val... | python | {
"resource": ""
} |
q227056 | FileStorage.save | train | def save(self, destination: BinaryIO, buffer_size: int=16384) -> None:
"""Save the file to the destination.
Arguments:
destination: A filename (str) or file object to write to.
buffer_size: Buffer size as used as length in
:func:`shutil.copyfileobj`.
"""
... | python | {
"resource": ""
} |
q227057 | Request.get_data | train | async def get_data(self, raw: bool=True) -> AnyStr:
"""The request body data."""
try:
body_future = asyncio.ensure_future(self.body)
raw_data = await asyncio.wait_for(body_future, timeout=self.body_timeout)
except asyncio.TimeoutError:
body_future.cancel()
... | python | {
"resource": ""
} |
q227058 | Websocket.accept | train | async def accept(
self,
headers: Optional[Union[dict, CIMultiDict, Headers]] = None,
subprotocol: Optional[str] = None,
) -> None:
"""Manually chose to accept the websocket connection.
Arguments:
headers: Additional headers to send with the acceptance... | python | {
"resource": ""
} |
q227059 | create_logger | train | def create_logger(app: 'Quart') -> Logger:
"""Create a logger for the app based on the app settings.
This creates a logger named quart.app that has a log level based
on the app configuration.
"""
logger = getLogger('quart.app')
if app.debug and logger.level == NOTSET:
logger.setLevel(D... | python | {
"resource": ""
} |
q227060 | create_serving_logger | train | def create_serving_logger() -> Logger:
"""Create a logger for serving.
This creates a logger named quart.serving.
"""
logger = getLogger('quart.serving')
if logger.level == NOTSET:
logger.setLevel(INFO)
logger.addHandler(serving_handler)
return logger | python | {
"resource": ""
} |
q227061 | create_cookie | train | def create_cookie(
key: str,
value: str='',
max_age: Optional[Union[int, timedelta]]=None,
expires: Optional[Union[int, float, datetime]]=None,
path: str='/',
domain: Optional[str]=None,
secure: bool=False,
httponly: bool=False,
) -> SimpleCookie:
"""C... | python | {
"resource": ""
} |
q227062 | Quart.name | train | def name(self) -> str:
"""The name of this application.
This is taken from the :attr:`import_name` and is used for
debugging purposes.
"""
if self.import_name == '__main__':
path = Path(getattr(sys.modules['__main__'], '__file__', '__main__.py'))
return p... | python | {
"resource": ""
} |
q227063 | Quart.jinja_env | train | def jinja_env(self) -> Environment:
"""The jinja environment used to load templates."""
if self._jinja_env is None:
self._jinja_env = self.create_jinja_environment()
return self._jinja_env | python | {
"resource": ""
} |
q227064 | Quart.auto_find_instance_path | train | def auto_find_instance_path(self) -> Path:
"""Locates the instace_path if it was not provided
"""
prefix, package_path = find_package(self.import_name)
if prefix is None:
return package_path / "instance"
return prefix / "var" / f"{self.name}-instance" | python | {
"resource": ""
} |
q227065 | Quart.make_config | train | def make_config(self, instance_relative: bool = False) -> Config:
"""Create and return the configuration with appropriate defaults."""
config = self.config_class(
self.instance_path if instance_relative else self.root_path,
DEFAULT_CONFIG,
)
config['ENV'] = get_en... | python | {
"resource": ""
} |
q227066 | Quart.create_url_adapter | train | def create_url_adapter(self, request: Optional[BaseRequestWebsocket]) -> Optional[MapAdapter]:
"""Create and return a URL adapter.
This will create the adapter based on the request if present
otherwise the app configuration.
"""
if request is not None:
host = request... | python | {
"resource": ""
} |
q227067 | Quart.create_jinja_environment | train | def create_jinja_environment(self) -> Environment:
"""Create and return the jinja environment.
This will create the environment based on the
:attr:`jinja_options` and configuration settings. The
environment will include the Quart globals by default.
"""
options = dict(se... | python | {
"resource": ""
} |
q227068 | Quart.select_jinja_autoescape | train | def select_jinja_autoescape(self, filename: str) -> bool:
"""Returns True if the filename indicates that it should be escaped."""
if filename is None:
return True
return Path(filename).suffix in {'.htm', '.html', '.xhtml', '.xml'} | python | {
"resource": ""
} |
q227069 | Quart.update_template_context | train | async def update_template_context(self, context: dict) -> None:
"""Update the provided template context.
This adds additional context from the various template context
processors.
Arguments:
context: The context to update (mutate).
"""
processors = self.temp... | python | {
"resource": ""
} |
q227070 | Quart.make_shell_context | train | def make_shell_context(self) -> dict:
"""Create a context for interactive shell usage.
The :attr:`shell_context_processors` can be used to add
additional context.
"""
context = {'app': self, 'g': g}
for processor in self.shell_context_processors:
context.upda... | python | {
"resource": ""
} |
q227071 | Quart.endpoint | train | def endpoint(self, endpoint: str) -> Callable:
"""Register a function as an endpoint.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.endpoint('name')
def endpoint():
...
Arguments:
endpoint... | python | {
"resource": ""
} |
q227072 | Quart.register_error_handler | train | def register_error_handler(
self, error: Union[Type[Exception], int], func: Callable, name: AppOrBlueprintKey=None,
) -> None:
"""Register a function as an error handler.
This is designed to be used on the application directly. An
example usage,
.. code-block:: python
... | python | {
"resource": ""
} |
q227073 | Quart.context_processor | train | def context_processor(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a template context processor.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.context_processor
def update_context(context):
... | python | {
"resource": ""
} |
q227074 | Quart.shell_context_processor | train | def shell_context_processor(self, func: Callable) -> Callable:
"""Add a shell context processor.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.shell_context_processor
def additional_context():
return context
... | python | {
"resource": ""
} |
q227075 | Quart.inject_url_defaults | train | def inject_url_defaults(self, endpoint: str, values: dict) -> None:
"""Injects default URL values into the passed values dict.
This is used to assist when building urls, see
:func:`~quart.helpers.url_for`.
"""
functions = self.url_value_preprocessors[None]
if '.' in endp... | python | {
"resource": ""
} |
q227076 | Quart.handle_url_build_error | train | def handle_url_build_error(self, error: Exception, endpoint: str, values: dict) -> str:
"""Handle a build error.
Ideally this will return a valid url given the error endpoint
and values.
"""
for handler in self.url_build_error_handlers:
result = handler(error, endpoi... | python | {
"resource": ""
} |
q227077 | Quart.handle_http_exception | train | async def handle_http_exception(self, error: Exception) -> Response:
"""Handle a HTTPException subclass error.
This will attempt to find a handler for the error and if fails
will fall back to the error response.
"""
handler = self._find_exception_handler(error)
if handle... | python | {
"resource": ""
} |
q227078 | Quart.handle_user_exception | train | async def handle_user_exception(self, error: Exception) -> Response:
"""Handle an exception that has been raised.
This should forward :class:`~quart.exception.HTTPException` to
:meth:`handle_http_exception`, then attempt to handle the
error. If it cannot it should reraise the error.
... | python | {
"resource": ""
} |
q227079 | Quart.before_request | train | def before_request(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a before request function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.before_request
def func():
...
Argum... | python | {
"resource": ""
} |
q227080 | Quart.before_websocket | train | def before_websocket(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a before websocket function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.before_websocket
def func():
...
... | python | {
"resource": ""
} |
q227081 | Quart.before_serving | train | def before_serving(self, func: Callable) -> Callable:
"""Add a before serving function.
This will allow the function provided to be called once before
anything is served (before any byte is received).
This is designed to be used as a decorator. An example usage,
.. code-block:... | python | {
"resource": ""
} |
q227082 | Quart.after_request | train | def after_request(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add an after request function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.after_request
def func(response):
return respo... | python | {
"resource": ""
} |
q227083 | Quart.after_websocket | train | def after_websocket(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add an after websocket function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.after_websocket
def func(response):
return... | python | {
"resource": ""
} |
q227084 | Quart.after_serving | train | def after_serving(self, func: Callable) -> Callable:
"""Add a after serving function.
This will allow the function provided to be called once after
anything is served (after last byte is sent).
This is designed to be used as a decorator. An example usage,
.. code-block:: pytho... | python | {
"resource": ""
} |
q227085 | Quart.teardown_request | train | def teardown_request(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a teardown request function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.teardown_request
def func():
...
... | python | {
"resource": ""
} |
q227086 | Quart.teardown_websocket | train | def teardown_websocket(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a teardown websocket function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.teardown_websocket
def func():
...
... | python | {
"resource": ""
} |
q227087 | Quart.register_blueprint | train | def register_blueprint(self, blueprint: Blueprint, url_prefix: Optional[str]=None) -> None:
"""Register a blueprint on the app.
This results in the blueprint's routes, error handlers
etc... being added to the app.
Arguments:
blueprint: The blueprint to register.
... | python | {
"resource": ""
} |
q227088 | Quart.open_session | train | async def open_session(self, request: BaseRequestWebsocket) -> Session:
"""Open and return a Session using the request."""
return await ensure_coroutine(self.session_interface.open_session)(self, request) | python | {
"resource": ""
} |
q227089 | Quart.save_session | train | async def save_session(self, session: Session, response: Response) -> None:
"""Saves the session to the response."""
await ensure_coroutine(self.session_interface.save_session)(self, session, response) | python | {
"resource": ""
} |
q227090 | Quart.do_teardown_request | train | async def do_teardown_request(
self,
exc: Optional[BaseException],
request_context: Optional[RequestContext]=None,
) -> None:
"""Teardown the request, calling the teardown functions.
Arguments:
exc: Any exception not handled that has caused the reques... | python | {
"resource": ""
} |
q227091 | Quart.do_teardown_websocket | train | async def do_teardown_websocket(
self,
exc: Optional[BaseException],
websocket_context: Optional[WebsocketContext]=None,
) -> None:
"""Teardown the websocket, calling the teardown functions.
Arguments:
exc: Any exception not handled that has caused th... | python | {
"resource": ""
} |
q227092 | Quart.run | train | def run(
self,
host: str='127.0.0.1',
port: int=5000,
debug: Optional[bool]=None,
use_reloader: bool=True,
loop: Optional[asyncio.AbstractEventLoop]=None,
ca_certs: Optional[str]=None,
certfile: Optional[str]=None,
... | python | {
"resource": ""
} |
q227093 | Quart.try_trigger_before_first_request_functions | train | async def try_trigger_before_first_request_functions(self) -> None:
"""Trigger the before first request methods."""
if self._got_first_request:
return
# Reverse the teardown functions, so as to match the expected usage
self.teardown_appcontext_funcs = list(reversed(self.tear... | python | {
"resource": ""
} |
q227094 | Quart.make_default_options_response | train | async def make_default_options_response(self) -> Response:
"""This is the default route function for OPTIONS requests."""
methods = _request_ctx_stack.top.url_adapter.allowed_methods()
return self.response_class('', headers={'Allow': ', '.join(methods)}) | python | {
"resource": ""
} |
q227095 | Quart.make_response | train | async def make_response(self, result: ResponseReturnValue) -> Response:
"""Make a Response from the result of the route handler.
The result itself can either be:
- A Response object (or subclass).
- A tuple of a ResponseValue and a header dictionary.
- A tuple of a Respons... | python | {
"resource": ""
} |
q227096 | Quart.full_dispatch_request | train | async def full_dispatch_request(
self, request_context: Optional[RequestContext]=None,
) -> Response:
"""Adds pre and post processing to the request dispatching.
Arguments:
request_context: The request context, optional as Flask
omits this argument.
"""
... | python | {
"resource": ""
} |
q227097 | Quart.preprocess_request | train | async def preprocess_request(
self, request_context: Optional[RequestContext]=None,
) -> Optional[ResponseReturnValue]:
"""Preprocess the request i.e. call before_request functions.
Arguments:
request_context: The request context, optional as Flask
omits this arg... | python | {
"resource": ""
} |
q227098 | Quart.dispatch_request | train | async def dispatch_request(
self, request_context: Optional[RequestContext]=None,
) -> ResponseReturnValue:
"""Dispatch the request to the view function.
Arguments:
request_context: The request context, optional as Flask
omits this argument.
"""
r... | python | {
"resource": ""
} |
q227099 | Quart.process_response | train | async def process_response(
self,
response: Response,
request_context: Optional[RequestContext]=None,
) -> Response:
"""Postprocess the request acting on the response.
Arguments:
response: The response after the request is finalized.
request_context: ... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.