Warning

This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

galaxy.web_stack package

Web application stack operations.

class galaxy.web_stack.ApplicationStackLogFilter(name='')[source]

Bases: Filter

filter(record)[source]

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

class galaxy.web_stack.ApplicationStack(app=None, config=None)[source]

Bases: object

name: str | None = None
prohibited_middleware: FrozenSet[str] = frozenset({})
log_filter_class

alias of ApplicationStackLogFilter

log_format = '%(name)s %(levelname)s %(asctime)s [pN:%(processName)s,p:%(process)d,tN:%(threadName)s] %(message)s'
server_name_template = '{server_name}'
default_app_name = 'main'
classmethod log_filter()[source]
classmethod get_app_kwds(config_section, app_name=None, for_paste_app=False)[source]
classmethod register_postfork_function(f, *args, post_fork_only=False, **kwargs)[source]
__init__(app=None, config=None)[source]
supports_returning() bool[source]
supports_skip_locked() bool[source]
get_preferred_handler_assignment_method()[source]
init_job_handling(job_config)[source]

Automatically add pools as handlers if they are named per predefined names and there is not an explicit job handler assignment configuration.

Also automatically set the preferred assignment method if pool handlers are found and an assignment method is not explicitly configured by the administrator.

init_late_prefork()[source]
log_startup()[source]
start()[source]
allowed_middleware(middleware)[source]
workers()[source]
property pool_name
property configured_pools
has_base_pool(pool_name)[source]
has_pool(pool_name)[source]
in_pool(pool_name)[source]
pool_members(pool_name)[source]
property facts
set_postfork_server_name(app)[source]
shutdown()[source]
class galaxy.web_stack.WebApplicationStack(app=None, config=None)[source]

Bases: ApplicationStack

name: str | None = 'Web'
class galaxy.web_stack.GunicornApplicationStack(app=None, config=None)[source]

Bases: ApplicationStack

name: str | None = 'Gunicorn'
do_post_fork = False
postfork_functions: List[Callable] = []
late_postfork_event = <threading.Event object>
late_postfork_thread: Thread
classmethod register_postfork_function(f, *args, post_fork_only=False, **kwargs)[source]
classmethod run_postfork()[source]
classmethod late_postfork()[source]
log_startup()[source]
class galaxy.web_stack.WeblessApplicationStack(app=None, config=None)[source]

Bases: ApplicationStack

name: str | None = 'Webless'
__init__(app=None, config=None)[source]
property configured_pools
in_pool(pool_name)[source]
pool_members(pool_name)[source]
galaxy.web_stack.application_stack_class() Type[ApplicationStack][source]

Returns the correct ApplicationStack class for the stack under which this Galaxy process is running.

galaxy.web_stack.application_stack_instance(app=None, config=None) ApplicationStack[source]
galaxy.web_stack.application_stack_log_filter()[source]
galaxy.web_stack.application_stack_log_formatter()[source]
galaxy.web_stack.register_postfork_function(f, *args, post_fork_only=False, **kwargs)[source]
galaxy.web_stack.get_app_kwds(config_section, app_name=None)[source]

Submodules

galaxy.web_stack.gunicorn_config module

Gunicorn config file based on https://gist.github.com/hynek/ba655c8756924a5febc5285c712a7946

galaxy.web_stack.gunicorn_config.is_preload_app()[source]
galaxy.web_stack.gunicorn_config.on_starting(server)[source]

Attach a set of IDs that can be temporarily re-used.

Used on reloads when each worker exists twice.

galaxy.web_stack.gunicorn_config.nworkers_changed(server, new_value, old_value)[source]

Gets called on startup too.

Set the current number of workers. Required if we raise the worker count temporarily using TTIN because server.cfg.workers won’t be updated and if one of those workers dies, we wouldn’t know the ids go that far.

galaxy.web_stack.gunicorn_config.on_reload(server)[source]

Add a full set of ids into overload so it can be re-used once.

galaxy.web_stack.gunicorn_config.when_ready(server)[source]
galaxy.web_stack.gunicorn_config.pre_fork(server, worker)[source]

Attach the next free worker_id before forking off.

galaxy.web_stack.gunicorn_config.post_fork(server, worker)[source]

Put worker_id and listeners into an env variable for further use within the app.

galaxy.web_stack.handlers module

Utilities for dealing with the Galaxy ‘handler’ process pattern.

A ‘handler’ is a named Python process running the Galaxy application responsible for some activity such as queuing up jobs or scheduling workflows.

class galaxy.web_stack.handlers.HANDLER_ASSIGNMENT_METHODS(value)[source]

Bases: str, Enum

An enumeration.

MEM_SELF = 'mem-self'
DB_SELF = 'db-self'
DB_PREASSIGN = 'db-preassign'
DB_TRANSACTION_ISOLATION = 'db-transaction-isolation'
DB_SKIP_LOCKED = 'db-skip-locked'
classmethod has_value(value)[source]
exception galaxy.web_stack.handlers.HandlerAssignmentSkip[source]

Bases: Exception

Exception for handler assignment methods to raise if the next method should be tried.

class galaxy.web_stack.handlers.ConfiguresHandlers[source]

Bases: object

DEFAULT_HANDLER_TAG = '_default_'
DEFAULT_BASE_HANDLER_POOLS: Tuple[str, ...] = ()
add_handler(handler_id, tags)[source]
static xml_to_dict(config, config_element)[source]
static get_xml_default(config, parent)[source]
property deterministic_handler_assignment
property is_handler

Indicate whether the current server is configured as a handler.

Returns:

bool

property handler_tags

Get an iterable of all configured handler tags.

property self_handler_tags

Get an iterable of the current process’s configured handler tags.

assign_handler(obj, configured=None, **kwargs)[source]

Set a job handler, flush obj

Called assignment methods should raise py:class:HandlerAssignmentSkip to indicate that the next method should be tried.

Parameters:
  • obj (instance of galaxy.model.Job or other model object with a set_handler() method.) – Object to assign a handler to (must be a model object with handler attribute and log_str callable).

  • configured (str or None.) – Preconfigured handler (ID, tag, or None) for the given object.

Returns:

bool – True on successful assignment, False otherwise.

galaxy.web_stack.message module

Web Application Stack worker messaging.

class galaxy.web_stack.message.ApplicationStackMessageDispatcher[source]

Bases: object

__init__()[source]
register_func(func, name=None)[source]
deregister_func(func=None, name=None)[source]
property handler_count
dispatch(msg_str)[source]
class galaxy.web_stack.message.ApplicationStackMessage(target=None, **kwargs)[source]

Bases: dict

default_handler = None
__init__(target=None, **kwargs)[source]
validate()[source]
encode()[source]
bind_default_handler(obj, name)[source]

Bind the default handler method to obj as attribute name.

This could also be implemented as a mixin class.

property target: str | None
property set_target: str | None
class galaxy.web_stack.message.ParamMessage(target=None, params=None, **kwargs)[source]

Bases: ApplicationStackMessage

__init__(target=None, params=None, **kwargs)[source]
validate()[source]
property params
class galaxy.web_stack.message.TaskMessage(target=None, params=None, **kwargs)[source]

Bases: ParamMessage

static default_handler(self, msg)[source]

Can be bound to an instance of any class that has message handling methods named like _handle_{task}_method

property task
class galaxy.web_stack.message.JobHandlerMessage(target=None, params=None, **kwargs)[source]

Bases: TaskMessage

target = 'job_handler'
class galaxy.web_stack.message.WorkflowSchedulingMessage(target=None, params=None, **kwargs)[source]

Bases: TaskMessage

target = 'workflow_scheduling'
galaxy.web_stack.message.decode(msg_str)[source]

galaxy.web_stack.transport module

Web application stack operations

class galaxy.web_stack.transport.ApplicationStackTransport(app, stack, dispatcher=None)[source]

Bases: object

SHUTDOWN_MSG = '__SHUTDOWN__'
__init__(app, stack, dispatcher=None)[source]

Pre-fork initialization.

init_late_prefork()[source]
start_if_needed()[source]
stop_if_unneeded()[source]
start()[source]

Post-fork initialization.

send_message(msg, dest)[source]
shutdown()[source]