initial scheduling test
This commit is contained in:
parent
90b3b70b25
commit
01370d92dc
1 changed files with 36 additions and 0 deletions
|
@ -0,0 +1,36 @@
|
||||||
|
import schedule
|
||||||
|
import threading
|
||||||
|
import functools
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
from Varken.iniparser import INIParser
|
||||||
|
from Varken.sonarr import SonarrAPI
|
||||||
|
|
||||||
|
def logging(function):
|
||||||
|
@functools.wraps(function)
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
print('LOG: Running job "%s"' % function.__name__)
|
||||||
|
result = function(*args, **kwargs)
|
||||||
|
print('LOG: Job "%s" completed' % function.__name__)
|
||||||
|
return result
|
||||||
|
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
@logging
|
||||||
|
def threaded(job):
|
||||||
|
thread = threading.Thread(target=job)
|
||||||
|
thread.start()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
CONFIG = INIParser()
|
||||||
|
|
||||||
|
if CONFIG.sonarr_enabled:
|
||||||
|
SONARR = SonarrAPI(CONFIG.sonarr_servers)
|
||||||
|
for server in CONFIG.sonarr_servers:
|
||||||
|
if server.queue:
|
||||||
|
schedule.every().minute.do(threaded, SONARR.get_queue)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
schedule.run_pending()
|
||||||
|
sleep(1)
|
||||||
|
|
Loading…
Reference in a new issue