deluge.component

class deluge.component.Component(name, interval=1, depend=None)

Bases: object

Component objects are singletons managed by the ComponentRegistry. When a new Component object is instantiated, it will be automatically registered with the ComponentRegistry.

The ComponentRegistry has the ability to start, stop, pause and shutdown the components registered with it.

Events:

start() - This method is called when the client has connected to a
Deluge core.
stop() - This method is called when the client has disconnected from a
Deluge core.
update() - This method is called every 1 second by default while the
Componented is in a Started state. The interval can be specified during instantiation. The update() timer can be paused by instructing the ComponentRegistry to pause this Component.
shutdown() - This method is called when the client is exiting. If the
Component is in a “Started” state when this is called, a call to stop() will be issued prior to shutdown().

States:

A Component can be in one of these 5 states.

Started - The Component has been started by the ComponentRegistry
and will have it’s update timer started.
Starting - The Component has had it’s start method called, but it hasn’t
fully started yet.

Stopped - The Component has either been stopped or has yet to be started.

Stopping - The Component has had it’s stop method called, but it hasn’t
fully stopped yet.
Paused - The Component has had it’s update timer stopped, but will
still be considered in a Started state.
exception deluge.component.ComponentAlreadyRegistered
Bases: exceptions.Exception
class deluge.component.ComponentRegistry

Bases: object

The ComponentRegistry holds a list of currently registered Component objects. It is used to manage the Components by starting, stopping, pausing and shutting them down.

deregister(name)

Deregisters a component from the registry. A stop will be issued to the component prior to deregistering it.

Parameter:name (string) – the name of the component
pause(names=[])

Pauses Components that are currently in a Started state. If names is specified, then it will only pause those Components, and if not it will pause all the registered Components.

Parameter:names (list) – a list of Components to pause
Returns:a Deferred object that will fire once all Components have been sucessfully paused
Return type:twisted.internet.defer.Deferred
register(obj)

Registers a component object with the registry. This is done automatically when a Component object is instantiated.

Parameter:obj (object) – the Component object
Raises ComponentAlreadyRegistered:
 if a component with the same name is already registered.
resume(names=[])

Resumes Components that are currently in a Paused state. If names is specified, then it will only resume those Components, and if not it will resume all the registered Components.

Parameter:names (list) – a list of Components to resume
Returns:a Deferred object that will fire once all Components have been sucessfully resumed
Return type:twisted.internet.defer.Deferred
shutdown()

Shutdowns all Components regardless of state. This will call stop() on call the components prior to shutting down. This should be called when the program is exiting to ensure all Components have a chance to properly shutdown.

Returns:a Deferred object that will fire once all Components have been sucessfully resumed
Return type:twisted.internet.defer.Deferred
start(names=[])

Starts Components that are currently in a Stopped state and their dependencies. If names is specified, will only start those Components and their dependencies and if not it will start all registered components.

Parameter:names (list) – a list of Components to start
Returns:a Deferred object that will fire once all Components have been sucessfully started
Return type:twisted.internet.defer.Deferred
stop(names=[])

Stops Components that are currently not in a Stopped state. If names is specified, then it will only stop those Components, and if not it will stop all the registered Components.

Parameter:names (list) – a list of Components to start
Returns:a Deferred object that will fire once all Components have been sucessfully stopped
Return type:twisted.internet.defer.Deferred
update()
Updates all Components that are in a Started state.
deluge.component.get(name)

Return a reference to a component.

Parameter:name (string) – the Component name to get
Returns:the Component object
Return type:object
Raises KeyError:
 if the Component does not exist

Previous topic

deluge.common

Next topic

deluge.config

This Page