mirror of
https://github.com/rembo10/headphones.git
synced 2026-03-21 12:19:27 +00:00
36 lines
765 B
Python
36 lines
765 B
Python
from cherrypy.process.plugins import SimplePlugin
|
|
from apscheduler.scheduler import Scheduler
|
|
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
|
|
self.sched.add_cron_job(updater.dbUpdate, hour=3)
|
|
self.sched.add_interval_job(searcher.searchNZB, hours=18)
|