mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
callback are executed in threads which are joined when done
This commit is contained in:
parent
b15af67bdb
commit
adb9749d63
1 changed files with 13 additions and 3 deletions
|
|
@ -19,6 +19,7 @@ class IdleManager(threading.Thread):
|
||||||
self.qaction = None
|
self.qaction = None
|
||||||
self.failed_icon = None
|
self.failed_icon = None
|
||||||
self._is_running = False
|
self._is_running = False
|
||||||
|
self.threads = []
|
||||||
|
|
||||||
def set_qaction(self, qaction, failed_icon):
|
def set_qaction(self, qaction, failed_icon):
|
||||||
self.qaction = qaction
|
self.qaction = qaction
|
||||||
|
|
@ -62,11 +63,20 @@ class IdleManager(threading.Thread):
|
||||||
thread_keyboard.start()
|
thread_keyboard.start()
|
||||||
try:
|
try:
|
||||||
while self.is_running:
|
while self.is_running:
|
||||||
|
if self.idle_time in self.time_callbacks:
|
||||||
|
for callback in self.time_callbacks[self.idle_time]:
|
||||||
|
thread = threading.Thread(target=callback)
|
||||||
|
thread.start()
|
||||||
|
self.threads.append(thread)
|
||||||
|
|
||||||
|
for thread in tuple(self.threads):
|
||||||
|
if not thread.isAlive():
|
||||||
|
thread.join()
|
||||||
|
self.threads.remove(thread)
|
||||||
|
|
||||||
self.idle_time += 1
|
self.idle_time += 1
|
||||||
if self.idle_time in self.time_signals:
|
|
||||||
for signal in self.time_signals[self.idle_time]:
|
|
||||||
signal.emit()
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
self.log.warning(
|
self.log.warning(
|
||||||
'Idle Manager service has failed', exc_info=True
|
'Idle Manager service has failed', exc_info=True
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue