components Package

base Module

Implements components and boot-steps.

This file was copied and adapted from celery.

copyright:
  1. 2009 - 2012 by Ask Solem.
license:

BSD, see LICENSE for more details.

class thriftpool.components.base.Component(parent, **kwargs)[source]

Bases: thriftpool.components.base.NewBase

A component.

The __init__() method is called when the component is bound to a parent object, and can as such be used to initialize attributes in the parent object at parent instantiation-time.

abstract = None

if set the component will not be registered, but can be used as a component base class.

create(parent)[source]

Create the component.

enabled = True

This provides the default for include_if().

include(parent)[source]
include_if(parent)[source]

An optional predicate that decided whether this component should be created.

instantiate(qualname, *args, **kwargs)[source]
last = False

This flag is reserved for the workers Consumer, since it is required to always be started last. There can only be one object marked with last in every namespace.

name = None

The name of the component, or the namespace and the name of the component separated by dot.

namespace = None

can be used to specify the namespace, if the name does not include it.

obj = None

Optional obj created by the create() method. This is used by StartStopComponents to keep the original service object.

requires = ()

List of component names this component depends on. Note that the dependencies must be in the same namespace.

class thriftpool.components.base.ComponentType[source]

Bases: type

Metaclass for components.

class thriftpool.components.base.Namespace(name=None, app=None)[source]

Bases: thriftpool.utils.mixin.LogsMixin

A namespace containing components.

Every component must belong to a namespace.

When component classes are created they are added to the mapping of unclaimed components. The components will be claimed when the namespace they belong to is created.

Parameters:
  • name – Set the name of this namespace.
  • app – Set the Celery app for this namespace.
apply(parent, **kwargs)[source]

Apply the components in this namespace to an object.

This will apply the __init__ and include methods of each components with the object as argument.

For StartStopComponents the services created will also be added the the objects components attribute.

bind_component(name, parent, **kwargs)[source]

Bind component to parent object and this namespace.

import_module(module)[source]
load_modules()[source]

Will load the component modules this namespace depends on.

modules()[source]

Subclasses can override this to return a list of modules to import before components are claimed.

name = None
class thriftpool.components.base.StartStopComponent(parent, **kwargs)[source]

Bases: thriftpool.components.base.Component

abort()[source]
include(parent)[source]
start()[source]
stop()[source]
terminable = False
terminate()[source]

broker Module

Execute external commands by this worker.

class thriftpool.components.broker.PerspectiveBroker(app, controller)[source]

Bases: thriftpool.utils.mixin.LogsMixin, thriftworker.utils.mixin.LoopMixin

Execute commands provided through pipe.

consumer[source]
incoming_stream[source]
outgoing_stream[source]
start[source]
stop[source]
streams[source]
class thriftpool.components.broker.PerspectiveBrokerComponent(parent, **kwargs)[source]

Bases: thriftpool.components.base.StartStopComponent

create(parent)[source]
name = 'broker'
namespace = 'worker'
requires = ('loop', 'acceptors', 'worker')
class thriftpool.components.broker.Stream(loop, fd)[source]

Bases: object

Wrapper for plain file descriptor.

start()[source]
stop(all_events=False)[source]
subscribe(listener)[source]
unsubscribe(listener)[source]
write(data)[source]

listeners Module

Contains component that hold listener pool.

class thriftpool.components.listeners.ListenersComponent(parent, **kwargs)[source]

Bases: thriftpool.components.base.StartStopComponent

create(parent)[source]
name = 'listeners'
namespace = 'manager'
class thriftpool.components.listeners.ListenersManager(app, listeners, processes)[source]

Bases: thriftpool.utils.mixin.LogsMixin

start()[source]

Start all registered listeners.

stop()[source]

Stop all registered listeners.

class thriftpool.components.listeners.ListenersManagerComponent(parent, **kwargs)[source]

Bases: thriftpool.components.base.StartStopComponent

create(parent)[source]
name = 'listeners_manager'
namespace = 'manager'
requires = ('loop', 'listeners', 'process_manager')

loop Module

class thriftpool.components.loop.BaseLoopComponent(parent, **kwargs)[source]

Bases: thriftpool.components.base.StartStopComponent

create(parent)[source]

processes Module

Manage process pool.

class thriftpool.components.processes.BaseClientHandler(application, request, **kwargs)[source]

Bases: thriftpool.components.processes.BaseHandler

get(*args)[source]
get_data(proxy)[source]
class thriftpool.components.processes.BaseHandler(application, request, **kwargs)[source]

Bases: gaffer.http.util.CorsHandler

initialize(clients)[source]
class thriftpool.components.processes.ClientsHandler(application, request, **kwargs)[source]

Bases: thriftpool.components.processes.BaseHandler

get()[source]
class thriftpool.components.processes.CounterHandler(application, request, **kwargs)[source]

Bases: thriftpool.components.processes.BaseClientHandler

get_data(proxy)[source]
class thriftpool.components.processes.ProcessManager(app, listeners, controller)[source]

Bases: thriftpool.utils.mixin.LogsMixin, thriftworker.utils.mixin.LoopMixin

Start and manage workers.

abort()[source]
get_start_time(process_id)[source]

When process was registered?

gevent_monkey = 'from gevent.monkey import patch_all; patch_all();'
initialized[source]

All workers started or not?

manager[source]
name_template = '[thriftworker-{0}] -c {1.CONCURRENCY} -k {1.WORKER_TYPE}'
process_name = 'worker'
script = 'from thriftpool.bin.thriftworker import main; main();'
start()[source]
stop()[source]
class thriftpool.components.processes.ProcessManagerComponent(parent, **kwargs)[source]

Bases: thriftpool.components.base.StartStopComponent

create(parent)[source]
name = 'process_manager'
namespace = 'manager'
requires = ('loop', 'listeners')
class thriftpool.components.processes.RedirectStream(loop, stream)[source]

Bases: object

Try to write to stream asynchronous.

write(data)[source]

Write data in asynchronous way.

class thriftpool.components.processes.StackHandler(application, request, **kwargs)[source]

Bases: thriftpool.components.processes.BaseClientHandler

get_data(proxy)[source]
class thriftpool.components.processes.TimerHandler(application, request, **kwargs)[source]

Bases: thriftpool.components.processes.BaseClientHandler

get_data(proxy)[source]

worker Module

Project Versions

Table Of Contents

Previous topic

bin Package

Next topic

controllers Package

This Page