mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
Chore: Background worker
This commit is contained in:
parent
b89289b686
commit
01116336f8
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user