This commit is contained in:
mol
2023-04-26 16:47:36 +08:00
parent 83969a26d9
commit 2f4742b84c
10 changed files with 224 additions and 29 deletions

View File

@ -1,18 +1,32 @@
import thread
from threading import Thread, Timer
from Rss import *
class RssManager():
def __init__(self, rss_options):
self.rss_list = [Rss(opt['id'], opt['url'], opt['rss_pipe_handler'], opt['result_handler']) for opt in rss_options]
self.rss_list = [Rss(opt['id'], opt['type'], opt['url'], opt['result_handler']) for opt in rss_options]
self.running = False
def run(self):
try:
for rss in rss_list:
thread.start_new_thread(rss.run)
for rss in self.rss_list:
print('Info: start async run')
t = Thread(target=rss.run)
t.start()
except:
print('Error: unable to start thread')
print('Info: start sync run')
for rss in rss_list:
for rss in self.rss_list:
rss.run()
def start(self):
# self.run()
self.running = True
while self.running:
self.timer = Timer(120, self.run)
self.timer.start()
self.timer.join()
def stop(self):
self.running = False