Skip to content

Commit 976f516

Browse files
committed
some work on properties in the threads
1 parent bdc4574 commit 976f516

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

appdaemon/threads.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ class Threading:
5252
last_stats_time: ClassVar[datetime.datetime] = datetime.datetime.fromtimestamp(0)
5353
callback_list: list[dict]
5454

55-
pin_threads: int = 0
56-
total_threads: int
57-
5855
next_thread: int = 0
5956
current_callbacks_executed: int = 0
6057
current_callbacks_fired: int = 0
@@ -84,20 +81,31 @@ def pin_apps(self) -> bool:
8481

8582
@pin_apps.setter
8683
def pin_apps(self, new: bool) -> None:
87-
"""Set whether each app should be pinned to a thread"""
8884
self.AD.config.pin_apps = new
8985

9086
@property
91-
def total_threads(self) -> int:
92-
"""Number of threads created for apps.
87+
def pin_threads(self) -> int | None:
88+
"Number of threads allocated to pinned apps"
89+
if self.AD.config.pin_threads is None:
90+
# If pin_threads is None, it means that all threads are pinned to apps
91+
return self.total_threads
92+
return self.AD.config.pin_threads
93+
94+
@pin_threads.setter
95+
def pin_threads(self, new: int) -> None:
96+
self.AD.config.pin_threads = new
97+
98+
@property
99+
def total_threads(self) -> int | None:
100+
"""Total number of threads created for apps
93101
94102
By default this is automatically calculated, but can also be manually configured by the user in
95103
``appdaemon.yaml``.
96104
"""
97105
return self.AD.config.total_threads
98106

99107
@total_threads.setter
100-
def total_threads(self, new: int):
108+
def total_threads(self, new: int) -> None:
101109
self.AD.config.total_threads = new
102110

103111
async def get_q_update(self):

0 commit comments

Comments
 (0)