From: Rishabh Dave Date: Mon, 16 Sep 2024 09:16:45 +0000 (+0530) Subject: mgr/vol: reuse code for spawning threads X-Git-Tag: v20.0.0~764^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=72395884f976c716ccc20c813d971b17b586ef90;p=ceph.git mgr/vol: reuse code for spawning threads Signed-off-by: Rishabh Dave --- diff --git a/src/pybind/mgr/volumes/fs/async_job.py b/src/pybind/mgr/volumes/fs/async_job.py index 83a119ca5564..0f63889cd532 100644 --- a/src/pybind/mgr/volumes/fs/async_job.py +++ b/src/pybind/mgr/volumes/fs/async_job.py @@ -137,10 +137,17 @@ class AsyncJobs(threading.Thread): self.threads = [] for i in range(self.nr_concurrent_jobs): - self.threads.append(JobThread(self, volume_client, name="{0}.{1}".format(self.name_pfx, i))) - self.threads[-1].start() + self.spawn_new_thread(i) self.start() + def spawn_new_thread(self, suffix): + t_name = f'{self.name_pfx}.{time.time()}.{suffix}' + log.debug(f'spawning new thread with name {t_name}') + t = JobThread(self, self.vc, name=t_name) + t.start() + + self.threads.append(t) + def set_wakeup_timeout(self): with self.lock: # not made configurable on purpose @@ -165,8 +172,7 @@ class AsyncJobs(threading.Thread): # Increase concurrency: create more threads. log.debug("creating new threads to job increase") for i in range(c, self.nr_concurrent_jobs): - self.threads.append(JobThread(self, self.vc, name="{0}.{1}.{2}".format(self.name_pfx, time.time(), i))) - self.threads[-1].start() + self.spawn_new_thread(i) self.cv.wait(timeout=self.wakeup_timeout) def shutdown(self):