Setting names for threads

This commit is contained in:
Fabio Manganiello 2019-01-10 23:08:29 +01:00
parent 0bbfaf4498
commit 56c7258c74
9 changed files with 21 additions and 8 deletions

View file

@ -44,6 +44,8 @@ class Backend(Thread):
:type kwargs: dict
"""
super().__init__(name='PlatypushBackend_' + self.__class__.__name__)
# If no bus is specified, create an internal queue where
# the received messages will be pushed
self.bus = bus or Bus()

View file

@ -145,7 +145,8 @@ class CameraPiBackend(Backend):
return
self.logger.info('Starting camera recording')
self._recording_thread = Thread(target=recording_thread)
self._recording_thread = Thread(target=recording_thread,
name='PiCameraRecorder')
self._recording_thread.start()

View file

@ -455,7 +455,9 @@ class HttpBackend(Backend):
self.logger.info('Initialized HTTP backend on port {}'.format(self.port))
webserver = self.webserver()
self.server_proc = Process(target=webserver.run, kwargs=kwargs)
self.server_proc = Process(target=webserver.run,
name='PlatypushWebServer',
kwargs=kwargs)
self.server_proc.start()
if not self.disable_websocket:

View file

@ -77,7 +77,7 @@ class HttpRequest(object):
self.logger.warning('Encountered an error while retrieving {}: {}'.
format(self.args.url, str(e)))
Thread(target=_thread_func).start()
Thread(target=_thread_func, name='PlatypushHttpPoll').start()
def get_new_items(self, response):

View file

@ -121,7 +121,9 @@ class MqttBackend(Backend):
return
if isinstance(msg, Request):
threading.Thread(target=response_thread, args=(msg,)).start()
threading.Thread(target=response_thread,
name='PlatypushMQTTResponseProcessor',
args=(msg,)).start()
super().run()
client = mqtt.Client()

View file

@ -198,7 +198,9 @@ class MusicSnapcastBackend(Backend):
for i, host in enumerate(self.hosts):
port = self.ports[i]
self._threads[host] = threading.Thread(
target=self._client(host, port))
target=self._client(host, port),
name='PlatypushSnapcastWorker'
)
self._threads[host].start()

View file

@ -88,7 +88,7 @@ class TcpBackend(Backend):
finally:
sock.close()
threading.Thread(target=_f_wrapper).start()
threading.Thread(target=_f_wrapper, name='PlatypushTCPListener').start()
def run(self):
super().run()

View file

@ -157,7 +157,9 @@ class EventHook(object):
if result.is_match:
logger.info('Running hook {} triggered by an event'.format(self.name))
threading.Thread(target=_thread_func, args=(result,)).start()
threading.Thread(target=_thread_func,
name='PlatypushEventHook_' + self.name,
args=(result,)).start()
# vim:sw=4:ts=4:et:

View file

@ -719,7 +719,9 @@ class LightHuePlugin(LightPlugin):
lights = self.lights
self.stop_animation()
self.animation_thread = Thread(target=_animate_thread, args=(lights,))
self.animation_thread = Thread(target=_animate_thread,
name='PlatypushLightHueAnimate',
args=(lights,))
self.animation_thread.start()