forked from rembo10/headphones
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththreadtools.py
More file actions
41 lines (34 loc) · 938 Bytes
/
threadtools.py
File metadata and controls
41 lines (34 loc) · 938 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
32
33
34
35
36
37
38
39
40
41
from cherrypy.process.plugins import SimplePlugin
from apscheduler.scheduler import Scheduler
import os
import time
import threading
import Queue
class threadtool(SimplePlugin):
sched = Scheduler()
thread = None
def __init__(self, bus):
SimplePlugin.__init__(self, bus)
def start(self):
self.running = True
if not self.thread:
self.thread = threading.Thread(target=self.run)
self.thread.start()
self.sched.start()
start.priority = 80
def stop(self):
self.running = False
if self.thread:
self.thread.join()
self.thread = None
self.sched.shutdown()
stop.priority = 10
def run(self):
import updater
import searcher
import mover
from webServer import database
if os.path.exists(database):
self.sched.add_cron_job(updater.dbUpdate, hour=4, minute=0, second=0)
self.sched.add_interval_job(searcher.searchNZB, hours=12)
#self.sched.add_interval_job(mover.moveFiles, minutes=10)