From 1560e2ace3eabe1297759eab1d7267c16290370c Mon Sep 17 00:00:00 2001
From: Piotr Maslanka <piotr.maslanka@ericsson.com>
Date: Mon, 4 Mar 2024 12:21:22 +0100
Subject: [PATCH] made CPUProfileBuilderThread use SingleStartThread

Change-Id: Ibb88378f0d807688fefb3270c548ef077395a6ca
---
 satella/instrumentation/cpu_time/collector.py | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/satella/instrumentation/cpu_time/collector.py b/satella/instrumentation/cpu_time/collector.py
index 8d1bd7a6..c041ab50 100644
--- a/satella/instrumentation/cpu_time/collector.py
+++ b/satella/instrumentation/cpu_time/collector.py
@@ -3,13 +3,13 @@ from __future__ import annotations
 import collections
 import multiprocessing
 import os
-import threading
 import time
 import typing as tp
 
 import psutil
 
 from satella.coding import for_argument
+from satella.coding.concurrent import SingleStartThread
 from satella.coding.decorators import repeat_forever
 from satella.coding.transforms import percentile
 from satella.time import parse_time_string
@@ -22,13 +22,13 @@ pCPUtimes = collections.namedtuple('pcputimes',
                                     'iowait'])
 
 
-class _CPUProfileBuilderThread(threading.Thread):
+class _CPUProfileBuilderThread(SingleStartThread):
     """
     A CPU profile builder thread and a core singleton object to use.
 
     :param window_seconds: the amount of seconds for which to collect data.
         Generally, this should be the interval during which your system cycles through all of
-        it's load, eg. if it asks it's devices each 5 minutes, the interval should be 300 seconds.
+        its load, eg. if it asks its devices each 5 minutes, the interval should be 300 seconds.
         Or a time string.
     :param refresh_each: time of seconds to sleep between rebuilding of profiles, or a time string.
     """
@@ -56,12 +56,6 @@ class _CPUProfileBuilderThread(threading.Thread):
             _CPUProfileBuilderThread.thread.start()
         return _CPUProfileBuilderThread.thread
 
-    def start(self) -> None:
-        if self.started:
-            return
-        self.started = True
-        super().start()
-
     def save_load(self, times: pCPUtimes) -> None:
         while len(self.own_load_average) > 3 and \
                 self.own_load_average[0][0] < self.own_load_average[-1][0] - self.window_size:
-- 
GitLab