Created
August 14, 2020 07:17
-
-
Save keddad/2683fdd133700a47c5a1200d078ef453 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing import Queue | |
from fetchers.base import Fetcher | |
from typing import List | |
import schedule | |
import time | |
import signal | |
from utils import signal_handler | |
signal.signal(signal.SIGINT, signal_handler) | |
def fetch_news(pass_to: Queue, fetchers: List[Fetcher]): | |
def put_news_to_query(pass_to: Queue, fetchers: List[Fetcher]): | |
for fet in fetchers: | |
for news in fet.latest_news(): | |
pass_to.put(news) | |
put_news_to_query(pass_to, fetchers) # Populate query on startup | |
schedule.every(5).minutes.do(put_news_to_query, pass_to, fetchers) | |
while True: | |
schedule.run_pending() | |
time.sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment