proNlp1/daemon.py

36 lines
804 B
Python
Raw Normal View History

2017-10-19 16:03:48 +00:00
from threading import Thread, Lock
2017-10-18 21:57:21 +00:00
from time import gmtime, strftime
2017-10-19 16:03:48 +00:00
from infoRet import get_data_rss
2017-10-18 21:57:21 +00:00
2017-10-19 16:03:48 +00:00
class Daemon(Thread):
def __init__(self):
Thread.__init__(self)
self.mutex = Lock()
self._quit = False
2017-10-18 21:57:21 +00:00
2017-10-19 16:03:48 +00:00
def stopped(self):
self.mutex.acquire()
val = self._quit
self.mutex.release()
return val
2017-10-18 21:57:21 +00:00
2017-10-19 16:03:48 +00:00
def stop(self):
self.mutex.acquire()
self._quit = True
self.mutex.release()
2017-10-18 21:57:21 +00:00
2017-10-19 16:03:48 +00:00
def run(self):
while True:
2017-10-26 21:12:30 +00:00
if str(strftime("%H:%M:%S", gmtime())) == ('12:00:00' or '24:00:00'):
2017-10-19 16:03:48 +00:00
get_data_rss()
print('Data capture finished at time' + str(strftime("%H:%M:%S", gmtime())))
2017-10-18 21:57:21 +00:00
2017-10-19 16:03:48 +00:00
def main_fct():
t = Daemon()
t.start()
2017-10-18 21:57:21 +00:00
2017-10-19 16:03:48 +00:00
if __name__ == "__main__":
main_fct()