Removed pp- prefix from the name of the spawned processes and threads

This commit is contained in:
Fabio Manganiello 2019-01-13 20:41:15 +01:00
parent e5d1dd3791
commit 2d8b2ba55a
8 changed files with 16 additions and 16 deletions

View file

@ -44,7 +44,7 @@ class Backend(Thread):
:type kwargs: dict :type kwargs: dict
""" """
self._thread_name = 'pp-' + self.__class__.__name__ self._thread_name = self.__class__.__name__
super().__init__(name=self._thread_name) super().__init__(name=self._thread_name)
# If no bus is specified, create an internal queue where # If no bus is specified, create an internal queue where

View file

@ -232,7 +232,7 @@ class HttpBackend(Backend):
def webserver(self): def webserver(self):
""" Web server main process """ """ Web server main process """
set_thread_name('pp-web-server') set_thread_name('WebServer')
basedir = os.path.dirname(inspect.getfile(self.__class__)) basedir = os.path.dirname(inspect.getfile(self.__class__))
template_dir = os.path.join(basedir, 'templates') template_dir = os.path.join(basedir, 'templates')
@ -418,7 +418,7 @@ class HttpBackend(Backend):
def websocket(self): def websocket(self):
""" Websocket main server """ """ Websocket main server """
import websockets import websockets
set_thread_name('pp-websocket-server') set_thread_name('WebsocketServer')
async def register_websocket(websocket, path): async def register_websocket(websocket, path):
address = websocket.remote_address[0] if websocket.remote_address \ address = websocket.remote_address[0] if websocket.remote_address \
@ -459,7 +459,7 @@ class HttpBackend(Backend):
webserver = self.webserver() webserver = self.webserver()
self.server_proc = Process(target=webserver.run, self.server_proc = Process(target=webserver.run,
name='pp-web-server', name='WebServer',
kwargs=kwargs) kwargs=kwargs)
self.server_proc.start() self.server_proc.start()

View file

@ -54,7 +54,7 @@ class HttpRequest(object):
def execute(self): def execute(self):
def _thread_func(): def _thread_func():
set_thread_name('pp-http-poll') set_thread_name('HttpPoll')
is_first_call = self.last_request_timestamp == 0 is_first_call = self.last_request_timestamp == 0
self.last_request_timestamp = time.time() self.last_request_timestamp = time.time()
@ -79,7 +79,7 @@ class HttpRequest(object):
self.logger.warning('Encountered an error while retrieving {}: {}'. self.logger.warning('Encountered an error while retrieving {}: {}'.
format(self.args.url, str(e))) format(self.args.url, str(e)))
Thread(target=_thread_func, name='pp-http-poll').start() Thread(target=_thread_func, name='HttpPoll').start()
def get_new_items(self, response): def get_new_items(self, response):

View file

@ -98,7 +98,7 @@ class MqttBackend(Backend):
def on_message(client, userdata, msg): def on_message(client, userdata, msg):
def response_thread(msg): def response_thread(msg):
set_thread_name('pp-mqtt-processor') set_thread_name('MQTTProcessor')
response = self.get_message_response(msg) response = self.get_message_response(msg)
if not response: if not response:
return return
@ -124,7 +124,7 @@ class MqttBackend(Backend):
if isinstance(msg, Request): if isinstance(msg, Request):
threading.Thread(target=response_thread, threading.Thread(target=response_thread,
name='pp-mqtt-processor', name='MQTTProcessor',
args=(msg,)).start() args=(msg,)).start()
super().run() super().run()

View file

@ -130,7 +130,7 @@ class MusicSnapcastBackend(Backend):
def _client(self, host, port): def _client(self, host, port):
def _thread(): def _thread():
set_thread_name('pp-snapcast-' + host) set_thread_name('Snapcast-' + host)
status = None status = None
try: try:
@ -201,7 +201,7 @@ class MusicSnapcastBackend(Backend):
port = self.ports[i] port = self.ports[i]
self._threads[host] = threading.Thread( self._threads[host] = threading.Thread(
target=self._client(host, port), target=self._client(host, port),
name='pp-snapcast' name='Snapcast-' + host
) )
self._threads[host].start() self._threads[host].start()

View file

@ -84,13 +84,13 @@ class TcpBackend(Backend):
sock.send(str(response).encode()) sock.send(str(response).encode())
def _f_wrapper(): def _f_wrapper():
set_thread_name('pp-tcp-listen') set_thread_name('TCPListener')
try: try:
_f() _f()
finally: finally:
sock.close() sock.close()
threading.Thread(target=_f_wrapper, name='pp-tcp-listen').start() threading.Thread(target=_f_wrapper, name='TCPListener').start()
def run(self): def run(self):
super().run() super().run()

View file

@ -150,7 +150,7 @@ class EventHook(object):
runs the hook actions if the condition is met """ runs the hook actions if the condition is met """
def _thread_func(result): def _thread_func(result):
set_thread_name('pp-event-' + self.name) set_thread_name('Event-' + self.name)
self.actions.execute(event=event, **result.parsed_args) self.actions.execute(event=event, **result.parsed_args)
result = self.matches_event(event) result = self.matches_event(event)
@ -159,7 +159,7 @@ class EventHook(object):
if result.is_match: if result.is_match:
logger.info('Running hook {} triggered by an event'.format(self.name)) logger.info('Running hook {} triggered by an event'.format(self.name))
threading.Thread(target=_thread_func, threading.Thread(target=_thread_func,
name='pp-event-' + self.name, name='Event-' + self.name,
args=(result,)).start() args=(result,)).start()

View file

@ -667,7 +667,7 @@ class LightHuePlugin(LightPlugin):
def _animate_thread(lights): def _animate_thread(lights):
set_thread_name('pp-hue-animate') set_thread_name('HueAnimate')
self.logger.info('Starting {} animation'.format( self.logger.info('Starting {} animation'.format(
animation, (lights or groups))) animation, (lights or groups)))
@ -722,7 +722,7 @@ class LightHuePlugin(LightPlugin):
self.stop_animation() self.stop_animation()
self.animation_thread = Thread(target=_animate_thread, self.animation_thread = Thread(target=_animate_thread,
name='pp-hue-animate', name='HueAnimate',
args=(lights,)) args=(lights,))
self.animation_thread.start() self.animation_thread.start()