nopasaran.controllers.factory.WorkerServerFactory¶
- class nopasaran.controllers.factory.WorkerServerFactory(state_machine, variable)¶
Bases:
ServerFactoryA factory for creating WorkerServerProtocol instances.
This factory is responsible for creating server protocols.
- __init__(state_machine, variable)¶
Initialize the WorkerServerFactory.
- Args:
state_machine: The state machine object. variable: The variable object.
Methods
__init__(state_machine, variable)Initialize the WorkerServerFactory.
buildProtocol(addr)Create an instance of a subclass of Protocol.
doStart()Make sure startFactory is called.
doStop()Make sure stopFactory is called.
forProtocol(protocol, *args, **kwargs)Create a factory for the given protocol.
Describe this factory for log messages.
This will be called before I begin listening on a Port or Connector.
This will be called before I stop listening on all Ports/Connectors.
Attributes
noisynumPorts- buildProtocol(addr: <InterfaceClass twisted.internet.interfaces.IAddress>) Protocol | None¶
Create an instance of a subclass of Protocol.
The returned instance will handle input on an incoming server connection, and an attribute “factory” pointing to the creating factory.
Alternatively, L{None} may be returned to immediately close the new connection.
Override this method to alter how Protocol instances get created.
@param addr: an object implementing L{IAddress}
- doStart()¶
Make sure startFactory is called.
Users should not call this function themselves!
- doStop()¶
Make sure stopFactory is called.
Users should not call this function themselves!
- classmethod forProtocol(protocol, *args, **kwargs)¶
Create a factory for the given protocol.
It sets the C{protocol} attribute and returns the constructed factory instance.
@param protocol: A L{Protocol} subclass
@param args: Positional arguments for the factory.
@param kwargs: Keyword arguments for the factory.
@return: A L{Factory} instance wired up to C{protocol}.
- logPrefix()¶
Describe this factory for log messages.
- protocol¶
alias of
WorkerServerProtocol
- startFactory()¶
This will be called before I begin listening on a Port or Connector.
It will only be called once, even if the factory is connected to multiple ports.
This can be used to perform ‘unserialization’ tasks that are best put off until things are actually running, such as connecting to a database, opening files, etcetera.
- stopFactory()¶
This will be called before I stop listening on all Ports/Connectors.
This can be overridden to perform ‘shutdown’ tasks such as disconnecting database connections, closing files, etc.
It will be called, for example, before an application shuts down, if it was connected to a port. User code should not call this function directly.