Warning

This document is for an in-development version 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.ApplicationStack(app=None, config=None)[source]

Bases: object

__init__(app=None, config=None)[source]
allowed_middleware(middleware)[source]
configured_pools
default_app_name = 'main'
deregister_message_handler(func=None, name=None)[source]
facts
classmethod get_app_kwds(config_section, app_name=None, for_paste_app=False)[source]
get_preferred_handler_assignment_method()[source]
has_base_pool(pool_name)[source]
has_pool(pool_name)[source]
in_pool(pool_name)[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]
classmethod log_filter()[source]
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'
log_startup()[source]
name = None
pool_members(pool_name)[source]
pool_name
prohibited_middleware = frozenset()
register_message_handler(func, name=None)[source]
classmethod register_postfork_function(f, *args, **kwargs)[source]
send_message(dest, msg=None, target=None, params=None, **kwargs)[source]
server_name_template = '{server_name}'
set_postfork_server_name(app)[source]
shutdown()[source]
start()[source]
supports_returning()[source]
supports_skip_locked()[source]
transport_class

alias of galaxy.web_stack.transport.ApplicationStackTransport

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

Bases: logging.Filter

filter(record)[source]
class galaxy.web_stack.GunicornApplicationStack(app=None, config=None)[source]

Bases: galaxy.web_stack.ApplicationStack

do_post_fork = False
classmethod late_postfork()[source]
late_postfork_event = <threading.Event object>
log_startup()[source]
name = 'Gunicorn'
postfork_functions = []
classmethod register_postfork_function(f, *args, **kwargs)[source]
classmethod run_postfork()[source]
class galaxy.web_stack.MessageApplicationStack(app=None, config=None)[source]

Bases: galaxy.web_stack.ApplicationStack

__init__(app=None, config=None)[source]
deregister_message_handler(func=None, name=None)[source]
init_late_prefork()[source]
register_message_handler(func, name=None)[source]
send_message(dest, msg=None, target=None, params=None, **kwargs)[source]
shutdown()[source]
start()[source]
class galaxy.web_stack.PasteApplicationStack(app=None, config=None)[source]

Bases: galaxy.web_stack.ApplicationStack

name = 'Python Paste'
class galaxy.web_stack.UWSGIApplicationStack(app=None, config=None)[source]

Bases: galaxy.web_stack.MessageApplicationStack

Interface to the uWSGI application stack. Supports running additional webless Galaxy workers as mules. Mules must be farmed to be communicable via uWSGI mule messaging, unfarmed mules are not supported.

Note that mules will use this as their stack class even though they start with the “webless” loading point.

__init__(app=None, config=None)[source]
bind_all_addrs = ('', '0.0.0.0', '[::]')
configured_pools
facts
classmethod get_app_kwds(config_section, app_name=None)[source]
in_pool(pool_name)[source]
instance_id
localhost_addrs = ('127.0.0.1', '[::1]')
log_filter_class

alias of UWSGILogFilter

log_format = '%(name)s %(levelname)s %(asctime)s [pN:%(processName)s,p:%(process)d,w:%(worker_id)s,m:%(mule_id)s,tN:%(threadName)s] %(message)s'
log_startup()[source]
name = 'uWSGI'
pool_members(pool_name)[source]
postfork_functions = []
prohibited_middleware = frozenset({'build_url_map', 'EvalException'})
classmethod register_postfork_function(f, *args, **kwargs)[source]
server_name_template = '{server_name}.{pool_name}.{instance_id}'
shutdown()[source]
start()[source]
transport_class

alias of galaxy.web_stack.transport.UWSGIFarmMessageTransport

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

Bases: logging.Filter

filter(record)[source]
class galaxy.web_stack.WeblessApplicationStack(app=None, config=None)[source]

Bases: galaxy.web_stack.ApplicationStack

__init__(app=None, config=None)[source]
configured_pools
in_pool(pool_name)[source]
name = 'Webless'
pool_members(pool_name)[source]
galaxy.web_stack.application_stack_class() → typing.Type[galaxy.web_stack.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) → galaxy.web_stack.ApplicationStack[source]
galaxy.web_stack.application_stack_log_filter()[source]
galaxy.web_stack.application_stack_log_formatter()[source]
galaxy.web_stack.get_app_kwds(config_section, app_name=None)[source]
galaxy.web_stack.register_postfork_function(f, *args, **kwargs)[source]

Submodules

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.ConfiguresHandlers[source]

Bases: object

DEFAULT_BASE_HANDLER_POOLS = ()
DEFAULT_HANDLER_TAG = '_default_'
UNSUPPORTED_HANDLER_ASSIGNMENT_METHODS = set()
add_handler(handler_id, tags)[source]
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.

deterministic_handler_assignment
static get_xml_default(config, parent)[source]
handler_tags

Get an iterable of all configured handler tags.

is_handler

Indicate whether the current server is configured as a handler.

Returns:bool
self_handler_tags

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

use_messaging
static xml_to_dict(config, config_element)[source]
class galaxy.web_stack.handlers.HANDLER_ASSIGNMENT_METHODS[source]

Bases: str, enum.Enum

An enumeration.

DB_PREASSIGN = 'db-preassign'
DB_SELF = 'db-self'
DB_SKIP_LOCKED = 'db-skip-locked'
DB_TRANSACTION_ISOLATION = 'db-transaction-isolation'
MEM_SELF = 'mem-self'
UWSGI_MULE_MESSAGE = 'uwsgi-mule-message'
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.

galaxy.web_stack.message module

Web Application Stack worker messaging.

class galaxy.web_stack.message.ApplicationStackMessage(target=None, **kwargs)[source]

Bases: dict

__init__(target=None, **kwargs)[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.

default_handler = None
encode()[source]
set_target
target
validate()[source]
class galaxy.web_stack.message.ApplicationStackMessageDispatcher[source]

Bases: object

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

Bases: galaxy.web_stack.message.TaskMessage

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

Bases: galaxy.web_stack.message.ApplicationStackMessage

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

Bases: galaxy.web_stack.message.ParamMessage

static default_handler(msg)[source]

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

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

Bases: galaxy.web_stack.message.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]
send_message(msg, dest)[source]
shutdown()[source]
start()[source]

Post-fork initialization.

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

Bases: galaxy.web_stack.transport.ApplicationStackTransport

Communication via uWSGI Mule Farm messages. Communication is unidirectional (workers -> mules).

__init__(app, stack, dispatcher=None)[source]
init_late_prefork()[source]
send_message(msg, dest)[source]
shutdown()[source]
start()[source]

Post-fork initialization.

This is mainly done here for the future possibility that we’ll be able to run mules post-fork without exec()ing. In a programmed mule it could be done at __init__ time.