-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwatch_thread.py
More file actions
52 lines (42 loc) · 1.09 KB
/
Copy pathwatch_thread.py
File metadata and controls
52 lines (42 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os, sys
from threading import Thread
from time import sleep
#my imports
import devices
import sensors
import controls
import sound
from threading import Event
import app_logger
import config
Running = None
thread = None
exit = Event()
def init():
global thread
global Running
Running = True
thread = Thread(target=listen_thread, args=(10, ))
thread.start()
def deinit():
global thread
global Running
Running = False
exit.set()
app_logger.info("start stoping "+os.path.basename(__file__))
if thread != None:
thread.join()
app_logger.info(__file__+" stopped")
def listen_thread(arg):
while Running:
try:
noisy_time=controls.get(controls.control_NoisyActions).do_check()
for control in controls.active:
control.do_check(noisy_time)
if not Running:
return
exit.wait(config.CHECK_PERIOD_S)
except Exception:
app_logger.exception("watch thread exception:")
exit.wait(config.CHECK_PERIOD_S) # for not spam
pass