From 2d8b2ba55aa5844da3d368c357880f9d476fa334 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 13 Jan 2019 20:41:15 +0100 Subject: [PATCH] Removed pp- prefix from the name of the spawned processes and threads --- platypush/backend/__init__.py | 2 +- platypush/backend/http/__init__.py | 6 +++--- platypush/backend/http/request/__init__.py | 4 ++-- platypush/backend/mqtt.py | 4 ++-- platypush/backend/music/snapcast.py | 4 ++-- platypush/backend/tcp.py | 4 ++-- platypush/event/hook.py | 4 ++-- platypush/plugins/light/hue/__init__.py | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/platypush/backend/__init__.py b/platypush/backend/__init__.py index 01115061..1f5dd778 100644 --- a/platypush/backend/__init__.py +++ b/platypush/backend/__init__.py @@ -44,7 +44,7 @@ class Backend(Thread): :type kwargs: dict """ - self._thread_name = 'pp-' + self.__class__.__name__ + self._thread_name = self.__class__.__name__ super().__init__(name=self._thread_name) # If no bus is specified, create an internal queue where diff --git a/platypush/backend/http/__init__.py b/platypush/backend/http/__init__.py index caef4f00..dc7df536 100644 --- a/platypush/backend/http/__init__.py +++ b/platypush/backend/http/__init__.py @@ -232,7 +232,7 @@ class HttpBackend(Backend): def webserver(self): """ Web server main process """ - set_thread_name('pp-web-server') + set_thread_name('WebServer') basedir = os.path.dirname(inspect.getfile(self.__class__)) template_dir = os.path.join(basedir, 'templates') @@ -418,7 +418,7 @@ class HttpBackend(Backend): def websocket(self): """ Websocket main server """ import websockets - set_thread_name('pp-websocket-server') + set_thread_name('WebsocketServer') async def register_websocket(websocket, path): address = websocket.remote_address[0] if websocket.remote_address \ @@ -459,7 +459,7 @@ class HttpBackend(Backend): webserver = self.webserver() self.server_proc = Process(target=webserver.run, - name='pp-web-server', + name='WebServer', kwargs=kwargs) self.server_proc.start() diff --git a/platypush/backend/http/request/__init__.py b/platypush/backend/http/request/__init__.py index 2872e8b9..b8f58ab0 100644 --- a/platypush/backend/http/request/__init__.py +++ b/platypush/backend/http/request/__init__.py @@ -54,7 +54,7 @@ class HttpRequest(object): def execute(self): def _thread_func(): - set_thread_name('pp-http-poll') + set_thread_name('HttpPoll') is_first_call = self.last_request_timestamp == 0 self.last_request_timestamp = time.time() @@ -79,7 +79,7 @@ class HttpRequest(object): self.logger.warning('Encountered an error while retrieving {}: {}'. 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): diff --git a/platypush/backend/mqtt.py b/platypush/backend/mqtt.py index f6bb5666..7ab522f7 100644 --- a/platypush/backend/mqtt.py +++ b/platypush/backend/mqtt.py @@ -98,7 +98,7 @@ class MqttBackend(Backend): def on_message(client, userdata, msg): def response_thread(msg): - set_thread_name('pp-mqtt-processor') + set_thread_name('MQTTProcessor') response = self.get_message_response(msg) if not response: return @@ -124,7 +124,7 @@ class MqttBackend(Backend): if isinstance(msg, Request): threading.Thread(target=response_thread, - name='pp-mqtt-processor', + name='MQTTProcessor', args=(msg,)).start() super().run() diff --git a/platypush/backend/music/snapcast.py b/platypush/backend/music/snapcast.py index 8c8873a4..2c3a25fc 100644 --- a/platypush/backend/music/snapcast.py +++ b/platypush/backend/music/snapcast.py @@ -130,7 +130,7 @@ class MusicSnapcastBackend(Backend): def _client(self, host, port): def _thread(): - set_thread_name('pp-snapcast-' + host) + set_thread_name('Snapcast-' + host) status = None try: @@ -201,7 +201,7 @@ class MusicSnapcastBackend(Backend): port = self.ports[i] self._threads[host] = threading.Thread( target=self._client(host, port), - name='pp-snapcast' + name='Snapcast-' + host ) self._threads[host].start() diff --git a/platypush/backend/tcp.py b/platypush/backend/tcp.py index c62c6a59..f586c8c3 100644 --- a/platypush/backend/tcp.py +++ b/platypush/backend/tcp.py @@ -84,13 +84,13 @@ class TcpBackend(Backend): sock.send(str(response).encode()) def _f_wrapper(): - set_thread_name('pp-tcp-listen') + set_thread_name('TCPListener') try: _f() finally: sock.close() - threading.Thread(target=_f_wrapper, name='pp-tcp-listen').start() + threading.Thread(target=_f_wrapper, name='TCPListener').start() def run(self): super().run() diff --git a/platypush/event/hook.py b/platypush/event/hook.py index a05cad08..7d6e9691 100644 --- a/platypush/event/hook.py +++ b/platypush/event/hook.py @@ -150,7 +150,7 @@ class EventHook(object): runs the hook actions if the condition is met """ 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) result = self.matches_event(event) @@ -159,7 +159,7 @@ class EventHook(object): if result.is_match: logger.info('Running hook {} triggered by an event'.format(self.name)) threading.Thread(target=_thread_func, - name='pp-event-' + self.name, + name='Event-' + self.name, args=(result,)).start() diff --git a/platypush/plugins/light/hue/__init__.py b/platypush/plugins/light/hue/__init__.py index 35eade16..74a1a00e 100644 --- a/platypush/plugins/light/hue/__init__.py +++ b/platypush/plugins/light/hue/__init__.py @@ -667,7 +667,7 @@ class LightHuePlugin(LightPlugin): def _animate_thread(lights): - set_thread_name('pp-hue-animate') + set_thread_name('HueAnimate') self.logger.info('Starting {} animation'.format( animation, (lights or groups))) @@ -722,7 +722,7 @@ class LightHuePlugin(LightPlugin): self.stop_animation() self.animation_thread = Thread(target=_animate_thread, - name='pp-hue-animate', + name='HueAnimate', args=(lights,)) self.animation_thread.start()