swh.scheduler.api.server module#
- class swh.scheduler.api.server.SchedulerServerApp(*args, backend_class=None, backend_factory=None, **kwargs)[source]#
Bases:
RPCServerApp
- extra_type_decoders: Dict[str, Callable] = {'last_visit_status': <enum 'LastVisitStatus'>, 'scheduler_model': <function <lambda>>}#
Value of extra_decoders passed to json_loads or msgpack_loads to be able to deserialize more object types.
- extra_type_encoders: List[Tuple[type, str, Callable]] = [(<class 'swh.scheduler.model.BaseSchedulerModel'>, 'scheduler_model', <function _encode_model_object>), (<enum 'LastVisitStatus'>, 'last_visit_status', <function _encode_enum>)]#
Value of extra_encoders passed to json_dumps or msgpack_dumps to be able to serialize more object types.
- json: JSONProvider#
Provides access to JSON methods. Functions in
flask.json
will call methods on this provider when the application context is active. Used for handling JSON requests and responses.An instance of
json_provider_class
. Can be customized by changing that attribute on a subclass, or by assigning to this attribute afterwards.The default,
DefaultJSONProvider
, uses Python’s built-injson
library. A different provider can use a different JSON library.New in version 2.2.
- url_build_error_handlers: t.List[t.Callable[[Exception, str, t.Dict[str, t.Any]], str]]#
A list of functions that are called by
handle_url_build_error()
whenurl_for()
raises aBuildError
. Each function is called witherror
,endpoint
andvalues
. If a function returnsNone
or raises aBuildError
, it is skipped. Otherwise, its return value is returned byurl_for
.New in version 0.9.
- before_first_request_funcs: t.List[ft.BeforeFirstRequestCallable]#
A list of functions that will be called at the beginning of the first request to this instance. To register a function, use the
before_first_request()
decorator.Deprecated since version 2.2: Will be removed in Flask 2.3. Run setup code when creating the application instead.
New in version 0.8.
- teardown_appcontext_funcs: t.List[ft.TeardownCallable]#
A list of functions that are called when the application context is destroyed. Since the application context is also torn down if the request ends this is the place to store code that disconnects from databases.
New in version 0.9.
- shell_context_processors: t.List[ft.ShellContextProcessorCallable]#
A list of shell context processor functions that should be run when a shell context is created.
New in version 0.11.
- blueprints: t.Dict[str, 'Blueprint']#
Maps registered blueprint names to blueprint objects. The dict retains the order the blueprints were registered in. Blueprints can be registered multiple times, this dict does not track how often they were attached.
New in version 0.7.
- extensions: dict#
a place where extensions can store application specific state. For example this is where an extension could store database engines and similar things.
The key must match the name of the extension module. For example in case of a “Flask-Foo” extension in flask_foo, the key would be
'foo'
.New in version 0.7.
- view_functions: t.Dict[str, t.Callable]#
A dictionary mapping endpoint names to view functions.
To register a view function, use the
route()
decorator.This data structure is internal. It should not be modified directly and its format may change at any time.
- error_handler_spec: t.Dict[ft.AppOrBlueprintKey, t.Dict[t.Optional[int], t.Dict[t.Type[Exception], ft.ErrorHandlerCallable]]]#
A data structure of registered error handlers, in the format
{scope: {code: {class: handler}}}
. Thescope
key is the name of a blueprint the handlers are active for, orNone
for all requests. Thecode
key is the HTTP status code forHTTPException
, orNone
for other exceptions. The innermost dictionary maps exception classes to handler functions.To register an error handler, use the
errorhandler()
decorator.This data structure is internal. It should not be modified directly and its format may change at any time.
- before_request_funcs: t.Dict[ft.AppOrBlueprintKey, t.List[ft.BeforeRequestCallable]]#
A data structure of functions to call at the beginning of each request, in the format
{scope: [functions]}
. Thescope
key is the name of a blueprint the functions are active for, orNone
for all requests.To register a function, use the
before_request()
decorator.This data structure is internal. It should not be modified directly and its format may change at any time.
- after_request_funcs: t.Dict[ft.AppOrBlueprintKey, t.List[ft.AfterRequestCallable]]#
A data structure of functions to call at the end of each request, in the format
{scope: [functions]}
. Thescope
key is the name of a blueprint the functions are active for, orNone
for all requests.To register a function, use the
after_request()
decorator.This data structure is internal. It should not be modified directly and its format may change at any time.
- teardown_request_funcs: t.Dict[ft.AppOrBlueprintKey, t.List[ft.TeardownCallable]]#
A data structure of functions to call at the end of each request even if an exception is raised, in the format
{scope: [functions]}
. Thescope
key is the name of a blueprint the functions are active for, orNone
for all requests.To register a function, use the
teardown_request()
decorator.This data structure is internal. It should not be modified directly and its format may change at any time.
- template_context_processors: t.Dict[ft.AppOrBlueprintKey, t.List[ft.TemplateContextProcessorCallable]]#
A data structure of functions to call to pass extra context values when rendering templates, in the format
{scope: [functions]}
. Thescope
key is the name of a blueprint the functions are active for, orNone
for all requests.To register a function, use the
context_processor()
decorator.This data structure is internal. It should not be modified directly and its format may change at any time.
- url_value_preprocessors: t.Dict[ft.AppOrBlueprintKey, t.List[ft.URLValuePreprocessorCallable]]#
A data structure of functions to call to modify the keyword arguments passed to the view function, in the format
{scope: [functions]}
. Thescope
key is the name of a blueprint the functions are active for, orNone
for all requests.To register a function, use the
url_value_preprocessor()
decorator.This data structure is internal. It should not be modified directly and its format may change at any time.
- url_default_functions: t.Dict[ft.AppOrBlueprintKey, t.List[ft.URLDefaultCallable]]#
A data structure of functions to call to modify the keyword arguments when generating URLs, in the format
{scope: [functions]}
. Thescope
key is the name of a blueprint the functions are active for, orNone
for all requests.To register a function, use the
url_defaults()
decorator.This data structure is internal. It should not be modified directly and its format may change at any time.
- swh.scheduler.api.server.load_and_check_config(config_path: str, type: str = 'postgresql') Dict [source]#
- Check the minimal configuration is set to run the api or raise an
error explanation.
- Parameters:
config_path – Configuration file path to load
type – Configuration type, for ‘postgresql’ type (the default), more checks are done.
- Raises:
Error if the setup is not as expected –
- Returns:
configuration as a dict