From 0bd294582baad0d6fb4d0fb6b615349833aced6b Mon Sep 17 00:00:00 2001 From: YoursFunny Date: Sun, 5 Jul 2026 19:27:47 +0800 Subject: [PATCH] refactor: move ThreadPoolExecutor import inside worker method for better encapsulation --- module/base/base.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/module/base/base.py b/module/base/base.py index 06ba45f..dda2e69 100644 --- a/module/base/base.py +++ b/module/base/base.py @@ -1,5 +1,3 @@ -from concurrent.futures import ThreadPoolExecutor - import module.config.server as server_ from module.base.button import Button, ButtonWrapper, ClickButton, match_template from module.base.timer import Timer @@ -50,11 +48,22 @@ class ModuleBase: self.interval_timer = {} @cached_class_property - def worker(self) -> ThreadPoolExecutor: + def worker(self): """ A thread pool to run things at background + + Examples: + ``` + def func(image): + logger.info('Update thread start') + with self.config.multi_set(): + self.dungeon_get_simuni_point(image) + self.dungeon_update_stamina(image) + ModuleBase.worker.submit(func, self.device.image) + ``` """ logger.hr('Creating worker') + from concurrent.futures import ThreadPoolExecutor pool = ThreadPoolExecutor(1) return pool