oio.event package

Submodules

oio.event.agent module

exception oio.event.agent.HaltServer(reason, exit_status=1)[source]

Bases: exceptions.BaseException

class oio.event.agent.Runner(conf_file, worker_class, **kwargs)[source]

Bases: object

SIGNALS = [1, 3, 2, 15]
SIG_NAMES = {1: 'hup', 2: 'int', 3: 'quit', 4: 'ill', 5: 'trap', 6: 'iot', 7: 'bus', 8: 'fpe', 9: 'kill', 10: 'usr1', 11: 'segv', 12: 'usr2', 13: 'pipe', 14: 'alrm', 15: 'term', 17: 'cld', 18: 'cont', 19: 'stop', 20: 'tstp', 21: 'ttin', 22: 'ttou', 23: 'urg', 24: 'xcpu', 25: 'xfsz', 26: 'vtalrm', 27: 'prof', 28: 'winch', 29: 'poll', 30: 'pwr', 31: 'sys', 34: 'rtmin', 64: 'rtmax'}
WORKER_START_ERROR = 3
configure_signals()[source]
halt(reason=None, exit_status=0)[source]
handle_chld(sig, frame)[source]
handle_hup()[source]
handle_int()[source]
handle_quit()[source]
handle_term()[source]
kill_worker(pid, sig)[source]
kill_workers(sig)[source]
manage_workers()[source]
reap_workers()[source]
run()[source]
signal(sig, frame)[source]
spawn_worker()[source]
spawn_workers()[source]
start()[source]
stop(graceful=True)[source]
x = 'TERM'
oio.event.agent.validate_msg(msg)[source]

oio.event.beanstalk module

class oio.event.beanstalk.BaseParser(socket_read_size)[source]

Bases: object

can_read()[source]
on_connect(connection)[source]
on_disconnect()[source]
read(size)[source]
read_response()[source]
class oio.event.beanstalk.Beanstalk(host=None, port=None, socket_timeout=None, socket_connect_timeout=None, socket_keepalive=None, socket_keepalive_options=None, connection=None, **kwargs)[source]

Bases: object

EXPECTED_ERR = {'bury': ['NOT_FOUND', 'OUT_OF_MEMORY'], 'delete': ['NOT_FOUND'], 'kick': ['OUT_OF_MEMORY'], 'kick-job': ['NOT_FOUND', 'OUT_OF_MEMORY'], 'list-tubes': [], 'peek': ['NOT_FOUND'], 'peek-buried': ['NOT_FOUND'], 'peek-delayed': ['NOT_FOUND'], 'peek-ready': ['NOT_FOUND'], 'put': ['JOB_TOO_BIG', 'BURIED', 'DRAINING', 'OUT_OF_MEMORY'], 'release': ['BURIED', 'NOT_FOUND', 'OUT_OF_MEMORY'], 'reserve': ['DEADLINE_SOON', 'TIMED_OUT'], 'reserve-with-timeout': ['DEADLINE_SOON', 'TIMED_OUT'], 'stats': [], 'stats-tube': ['NOT_FOUND'], 'use': [], 'watch': []}
EXPECTED_OK = {'bury': ['BURIED'], 'delete': ['DELETED'], 'kick': ['KICKED'], 'kick-job': ['KICKED'], 'list-tubes': ['OK'], 'peek': ['FOUND'], 'peek-buried': ['FOUND'], 'peek-delayed': ['FOUND'], 'peek-ready': ['FOUND'], 'put': ['INSERTED'], 'release': ['RELEASED'], 'reserve': ['RESERVED'], 'reserve-with-timeout': ['RESERVED'], 'stats': ['OK'], 'stats-tube': ['OK'], 'use': ['USING'], 'watch': ['WATCHING']}
RESPONSE_CALLBACKS = {'list-tubes': <function parse_yaml at 0x7fdf92a64398>, 'peek': <function parse_body at 0x7fdf92a64410>, 'peek-buried': <function parse_body at 0x7fdf92a64410>, 'peek-delayed': <function parse_body at 0x7fdf92a64410>, 'peek-ready': <function parse_body at 0x7fdf92a64410>, 'reserve': <function parse_body at 0x7fdf92a64410>, 'reserve-with-timeout': <function parse_body at 0x7fdf92a64410>, 'stats': <function parse_yaml at 0x7fdf92a64398>, 'stats-tube': <function parse_yaml at 0x7fdf92a64398>}
bury(job_id, priority=2147483648)[source]
close()[source]
delete(job_id)[source]
drain_buried(tube)[source]
drain_tube(tube, timeout=0.0)[source]

Delete all jobs from the specified tube.

execute_command(*args, **kwargs)[source]
classmethod from_url(url, **kwargs)[source]
kick(bound=1000)[source]

Move jobs into the ready queue. If there are any buried jobs, it will only kick buried jobs. Otherwise it will kick delayed jobs.

Parameters:bound (int) – upper bound on the number of jobs to kick
kick_job(job_id)[source]

Variant of` kick` that operates with a single job.

Parameters:job_id (str) – the job id to kick
parse_response(connection, command_name, **kwargs)[source]
peek_buried()[source]

Read the next buried job without kicking it.

peek_ready()[source]

read the next ready job without reserving it.

put(body, priority=2147483648, delay=0, ttr=120)[source]
release(job_id, priority=2147483648, delay=0)[source]
reserve(timeout=None)[source]
stats()[source]
stats_tube(tube)[source]
tubes()[source]
use(tube)[source]
wait_for_ready_job(tube, timeout=inf, poll_interval=0.2)[source]

Wait until the the specified tube has a ready job, or the timeout expires.

wait_until_empty(tube, timeout=inf, poll_interval=0.2, initial_delay=0.0)[source]

Wait until the the specified tube is empty, or the timeout expires.

watch(tube)[source]
exception oio.event.beanstalk.BeanstalkError[source]

Bases: exceptions.Exception

class oio.event.beanstalk.BeanstalkdListener(addr, tube, logger, **kwargs)[source]

Bases: oio.event.beanstalk.TubedBeanstalkd

fetch_job(on_job, timeout=None, **kwargs)[source]
fetch_jobs(on_job, reserve_timeout=None, **kwargs)[source]
class oio.event.beanstalk.BeanstalkdSender(addr, tube, logger, low_limit=512, high_limit=1024, **kwargs)[source]

Bases: oio.event.beanstalk.TubedBeanstalkd

Send jobs to the specified beanstalkd tube, until the specified high_limit is reached.

job_done()[source]

Declare that a job previously sent by this sender has been fully processed (the sender received a response, or does not expect one).

send_event(event, **kwargs)[source]

Deprecated

send_job(job, priority=2147483648, delay=0, **kwargs)[source]

Send a job, if the queue has not reached its size limit.

Returns:True if the job has been sent, False otherwise.
class oio.event.beanstalk.Connection(host=None, port=None, use_tubes=None, watch_tubes=None, socket_timeout=None, socket_connect_timeout=None, socket_keepalive=False, socket_keepalive_options=None, encoding='utf-8', socket_read_size=65536)[source]

Bases: object

connect()[source]
disconnect()[source]
classmethod from_url(url, **kwargs)[source]
on_connect()[source]
pack_command(command, body, *args)[source]
read_body(size)[source]
read_response()[source]
send_command(command, *args, **kwargs)[source]
use(tube)[source]
watch(tube)[source]
exception oio.event.beanstalk.ConnectionError[source]

Bases: oio.event.beanstalk.BeanstalkError

exception oio.event.beanstalk.InvalidResponse[source]

Bases: oio.event.beanstalk.BeanstalkError

class oio.event.beanstalk.Reader(socket, socket_read_size)[source]

Bases: object

close()[source]
length
purge()[source]
read(length)[source]
readline()[source]
exception oio.event.beanstalk.ResponseError[source]

Bases: oio.event.beanstalk.BeanstalkError

exception oio.event.beanstalk.TimeoutError[source]

Bases: oio.event.beanstalk.BeanstalkError

class oio.event.beanstalk.TubedBeanstalkd(addr, tube, logger, **kwargs)[source]

Bases: object

Beanstalkd wrapper that will talk to a single tube.

close()[source]

Disconnect the wrapped Beanstalkd client.

oio.event.beanstalk.dict_merge(*dicts)[source]
oio.event.beanstalk.parse_body(connection, response, **kwargs)[source]
oio.event.beanstalk.parse_yaml(connection, response, **kwargs)[source]

oio.event.client module

class oio.event.client.EventClient(conf, **kwargs)[source]

Bases: object

beanstalk
exhume(limit=1000, tube=None)[source]

Move buried or delayed jobs into the ready queue.

stats(tube=None)[source]

oio.event.consumer module

class oio.event.consumer.EventWorker(*args, **kwargs)[source]

Bases: oio.event.consumer.Worker

get_handler(event)[source]
handle(beanstalk)[source]
init()[source]
notify()[source]

TODO

process_event(job_id, event, beanstalk)[source]
run()[source]
safe_decode_job(job_id, data)[source]
exception oio.event.consumer.StopServe[source]

Bases: exceptions.Exception

class oio.event.consumer.Worker(ppid, conf, logger)[source]

Bases: object

SIGNALS = [1, 3, 2, 15, 17]
handle_exit(sig, frame)[source]
handle_quit(sig, frame)[source]
init()[source]
init_signals()[source]
parent_alive()[source]
pid
run()[source]
x = 'CHLD'

oio.event.evob module

class oio.event.evob.Event(env)[source]

Bases: object

data
event_type
job_id
reqid
url
when
exception oio.event.evob.EventException(*args, **kwargs)[source]

Bases: oio.event.evob.Response, exceptions.Exception

class oio.event.evob.EventTypes[source]

Bases: object

Enum class for event type names.

ACCOUNT_SERVICES = 'account.services'
CHUNK_DELETED = 'storage.chunk.deleted'
CHUNK_NEW = 'storage.chunk.new'
CONTAINER_DELETED = 'storage.container.deleted'
CONTAINER_EVENTS = ('storage.container.deleted', 'storage.container.new', 'storage.container.state', 'storage.container.update')
CONTAINER_NEW = 'storage.container.new'
CONTAINER_STATE = 'storage.container.state'
CONTAINER_UPDATE = 'storage.container.update'
CONTENT_APPEND = 'storage.content.append'
CONTENT_BROKEN = 'storage.content.broken'
CONTENT_DELETED = 'storage.content.deleted'
CONTENT_EVENTS = ('storage.content.append', 'storage.content.broken', 'storage.content.deleted', 'storage.content.new', 'storage.content.perfectible', 'storage.content.rebuilt', 'storage.content.update')
CONTENT_NEW = 'storage.content.new'
CONTENT_PERFECTIBLE = 'storage.content.perfectible'
CONTENT_REBUILT = 'storage.content.rebuilt'
CONTENT_UPDATE = 'storage.content.update'
META2_DELETED = 'storage.meta2.deleted'
XCUTE_TASKS = 'xcute.tasks'
class oio.event.evob.Response(body=None, status=200, event=None, **kwargs)[source]

Bases: object

class oio.event.evob.StatusMap[source]

Bases: object

oio.event.evob.is_error(status)[source]
oio.event.evob.is_success(status)[source]

oio.event.loader module

class oio.event.loader.AttrDict[source]

Bases: dict

class oio.event.loader.ConfigLoader(filename)[source]

Bases: object

absolute_name(name)[source]
find_config_section(obj_type, name=None)[source]
get_context(obj_type, name=None, global_conf=None)[source]
get_sections(prefix=None)[source]
class oio.event.loader.CustomConfigParser(filename, *args, **kwargs)[source]

Bases: ConfigParser.ConfigParser

class oio.event.loader.EggLoader(spec)[source]

Bases: oio.event.loader._Loader

find_egg_ep(obj_type, name=None)[source]
get_context(obj_type, name=None, global_conf=None)[source]
class oio.event.loader.LoaderContext(obj, obj_type, protocol, global_conf, local_conf, loader, distribution=None, ep_name=None)[source]

Bases: object

config()[source]
create(**kwargs)[source]
oio.event.loader.loadcontext(obj_type, uri, name=None, global_conf=None)[source]
oio.event.loader.loadhandler(loader, name, global_conf=None, **kwargs)[source]
oio.event.loader.loadhandlers(path, global_conf=None, **kwargs)[source]

Module contents