Add the ability to define the `BaseWorker.set_proctitle` flag

This patch allows to define the `BaseWorker.set_proctitle`` after
the initialization, needed to define the process title or not when
the process is started. When a ``BaseWorker`` is spawned in a
thread instead of a single process, this worker should not modify
the process title that should have been defined by the main thread.

That is happening, for example, with the workers spawned in the
``AllServicesNeutronWorker`` class. This class is defining the
process title as "neutron-server: services worker", but the new
workers spawned (``PeriodicWorker``) are re-writting the process
name to "neutron-server: periodic worker"

Change-Id: I744343804cd6b6a4bc7353502d7a0295800b37bd
Related-Bug: #2069595
This commit is contained in:
Rodolfo Alonso Hernandez 2024-06-17 10:35:59 +00:00
parent 7674b4b666
commit 2a13651df8

View File

@ -78,6 +78,14 @@ class BaseWorker(service.ServiceBase):
"""
return self._worker_process_count
@property
def set_proctitle(self):
return self._set_proctitle
@set_proctitle.setter
def set_proctitle(self, value):
self._set_proctitle = value
def setproctitle(self, name="neutron-server", desc=None):
if self._set_proctitle == "off" or os.getpid() == self._my_pid:
return