diff --git a/platypush/backend/__init__.py b/platypush/backend/__init__.py index 3aafa7ee..34da8919 100644 --- a/platypush/backend/__init__.py +++ b/platypush/backend/__init__.py @@ -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() diff --git a/platypush/backend/camera/pi.py b/platypush/backend/camera/pi.py index 7c419a01..2e595cb7 100644 --- a/platypush/backend/camera/pi.py +++ b/platypush/backend/camera/pi.py @@ -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() diff --git a/platypush/backend/http/__init__.py b/platypush/backend/http/__init__.py index 7ac371d6..b9a9df7b 100644 --- a/platypush/backend/http/__init__.py +++ b/platypush/backend/http/__init__.py @@ -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: diff --git a/platypush/backend/http/request/__init__.py b/platypush/backend/http/request/__init__.py index feebd94e..968c94ec 100644 --- a/platypush/backend/http/request/__init__.py +++ b/platypush/backend/http/request/__init__.py @@ -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): diff --git a/platypush/backend/mqtt.py b/platypush/backend/mqtt.py index ea563851..fc024653 100644 --- a/platypush/backend/mqtt.py +++ b/platypush/backend/mqtt.py @@ -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() diff --git a/platypush/backend/music/snapcast.py b/platypush/backend/music/snapcast.py index 2cc3d717..772fa790 100644 --- a/platypush/backend/music/snapcast.py +++ b/platypush/backend/music/snapcast.py @@ -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() diff --git a/platypush/backend/tcp.py b/platypush/backend/tcp.py index b5a7faf1..23c48d9c 100644 --- a/platypush/backend/tcp.py +++ b/platypush/backend/tcp.py @@ -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() diff --git a/platypush/event/hook.py b/platypush/event/hook.py index c7314e9e..467927ed 100644 --- a/platypush/event/hook.py +++ b/platypush/event/hook.py @@ -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: diff --git a/platypush/plugins/light/hue/__init__.py b/platypush/plugins/light/hue/__init__.py index 8536e70d..9d8be2d3 100644 --- a/platypush/plugins/light/hue/__init__.py +++ b/platypush/plugins/light/hue/__init__.py @@ -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()