-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServiceModule.py
More file actions
31 lines (26 loc) · 873 Bytes
/
ServiceModule.py
File metadata and controls
31 lines (26 loc) · 873 Bytes
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
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import time
import thread,os,sys
import Common
class RunService:
def __init__(self):
self.logger = Common.getLogger('RunService')
thread.start_new(self.do_something, tuple())
while True:
if getattr(sys,'stopservice', False):
break
#sys.exit()
time.sleep(0.3)
def do_something(self):
'''
Do something
'''
while True:
f = open(os.path.join(Common.DIR_PATH, 'test.txt') , 'a')
f.write("current local time: %d-%d-%d %d:%d:%d\n" % time.localtime()[:6])
f.close()
self.logger.info("xxxxxxxxxxxx: %d-%d-%d %d:%d:%d" % time.localtime()[:6])
time.sleep(3)
if __name__ == "__main__":
RunService()