Go to the latest version of this document.

# ``twisted`.`application`.`service`.`IService``

interface documentation

`class IService(Interface): (source)`

Known implementations: `twisted.application.service.Service`

View In Hierarchy

A service.

Run start-up and shut-down code at the appropriate times.

Method | `disownServiceParent` | Use this API to remove an `IService` from an `IServiceCollection`.
Method | `privilegedStartService` | Do preparation work for starting the service.
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).
Method | `startService` | Start the service.
Method | `stopService` | Stop the service.
Attribute | `name` | A `str` which is the name of the service or `None`.
Attribute | `parent` | An `IServiceCollection` which is the parent or `None`.
Attribute | `running` | A `boolean` which indicates whether the service is running.

def disownServiceParent(): (source)

Use this API to remove an `IService` from an `IServiceCollection`.

This method is used symmetrically with `setServiceParent` in that it sets the `parent` attribute on the child.

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`).

def privilegedStartService(): (source)

Do preparation work for starting the service.

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

def setName(name): (source)

Set the name of the service.

Parameters
name:`str` | Undocumented

Raises
`RuntimeError` | Raised if the service already has a parent.

def setServiceParent(parent): (source)

Set the parent of the service. This method is responsible for setting the `parent` attribute on this service (the child service).

Parameters
parent:`IServiceCollection` | Undocumented

Raises
`RuntimeError` | Raised if the service already has a parent or if the service has a name and the parent already has a child by that name.

def startService(): (source)

Start the service.

def stopService(): (source)

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`).

name = (source)

A `str` which is the name of the service or `None`.

parent = (source)

An `IServiceCollection` which is the parent or `None`.

running = (source)

A `boolean` which indicates whether the service is running.