# ``twisted`.`application`.`service`.`MultiService``

class documentation

`class MultiService(Service): (source)`

Known subclasses: `twisted.mail.mail.MailService`, `twisted.words.protocols.jabber.component.ServiceManager`

Implements interfaces: `twisted.application.service.IServiceCollection`

View In Hierarchy

Straightforward Service Container.

Hold a collection of services, and manage them in a simplistic way. No service will wait for another, but this object itself will not finish shutting down until all of its child services will finish.

Method | `__init__` | Undocumented
Method | `__iter__` | Get an iterator over all child services.
Method | `addService` | Add a child service.
Method | `getServiceNamed` | Get the child service with a given name.
Method | `privilegedStartService` | Do preparation work for starting the service.
Method | `removeService` | Remove a child service.
Method | `startService` | Start the service.
Method | `stopService` | Stop the service.
Instance Variable | `namedServices` | Undocumented
Instance Variable | `parent` | An `IServiceCollection` which is the parent or `None`.
Instance Variable | `services` | Undocumented

Inherited from `Service`:

Method | `__getstate__` | Undocumented
Method | `disownServiceParent` | Use this API to remove an `IService` from an `IServiceCollection`.
Method | `setName` | Set the name of the service.
Method | `setServiceParent` | Set the parent of the service. This method is responsible for setting the `parent` attribute on this service (the child service).
Instance Variable | `name` | A `str` which is the name of the service or `None`.
Instance Variable | `running` | A `boolean` which indicates whether the service is running.

def __init__(self): (source)
overridden in `twisted.mail.mail.MailService`, `twisted.words.protocols.jabber.component.ServiceManager`

Undocumented

def __iter__(self): (source)
from `twisted.application.service.IServiceCollection`
Get an iterator over all child services.
def addService(self, service): (source)
from `twisted.application.service.IServiceCollection`

Add a child service.

Only implementations of `IService.setServiceParent` should use this method.

Parameters
service:`IService` | Undocumented
Raises
`RuntimeError` | Raised if the service has a child with the given name.

def getServiceNamed(self, name): (source)
from `twisted.application.service.IServiceCollection`
Get the child service with a given name.

Parameters
name:`str` | Undocumented
Returns
`IService` | Undocumented
Raises
`KeyError` | Raised if the service has no child with the given name.

def privilegedStartService(self): (source)
from `twisted.application.service.IService`
overrides `twisted.application.service.Service.privilegedStartService`

Do preparation work for starting the service.

Here things which should be done before changing directory, root or shedding privileges are done.

def removeService(self, service): (source)
from `twisted.application.service.IServiceCollection`

Remove a child service.

Only implementations of `IService.disownServiceParent` should use this method.

Parameters
service:`IService` | Undocumented
Returns
`Deferred` | a `Deferred` which is triggered when the service has finished shutting down. If shutting down is immediate, a value can be returned (usually, `None`).
Raises
`ValueError` | Raised if the given service is not a child.

def startService(self): (source)
from `twisted.application.service.IService`
overrides `twisted.application.service.Service.startService`
Start the service.
def stopService(self): (source)
from `twisted.application.service.IService`
overrides `twisted.application.service.Service.stopService`
Stop the service.

Returns
`Deferred` | a `Deferred` which is triggered when the service has finished shutting down. If shutting down is immediate, a value can be returned (usually, `None`).

namedServices: `dict` = (source)

Undocumented

parent = (source)
from `twisted.application.service.IService`
overrides `twisted.application.service.Service.parent`
An `IServiceCollection` which is the parent or `None`.
services: `list` = (source)

Undocumented