neutron_lib.worker module

class neutron_lib.worker.BaseWorker(worker_process_count=1, set_proctitle='on', desc=None)

Bases: ServiceBase

Partial implementation of the ServiceBase ABC.

Subclasses will still need to add the other abstract methods defined in service.ServiceBase. See oslo_service for more details.

If a plugin needs to handle synchronization with the Neutron database and do this only once instead of in every API worker, for instance, it would define a BaseWorker class and the plugin would have get_workers return an array of BaseWorker instances. For example:

class MyPlugin(...):
    def get_workers(self):
        return [MyPluginWorker()]

class MyPluginWorker(BaseWorker):
    def start(self):
        super(MyPluginWorker, self).start()
        do_sync()
property set_proctitle
setproctitle(name='neutron-server', desc=None)
start(name='neutron-server', desc=None)

Start the worker.

If worker_process_count is greater than 0, a callback notification is sent. Subclasses should call this method before doing their own start() work.

Automatically sets the process title to indicate that this is a child worker, customizable via the name and desc arguments.

Returns:

None

property worker_process_count

The worker’s process count.

Returns:

The number of processes to spawn for this worker.