Skip to content

Instantly share code, notes, and snippets.

@keddad
Created August 14, 2020 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keddad/2683fdd133700a47c5a1200d078ef453 to your computer and use it in GitHub Desktop.
Save keddad/2683fdd133700a47c5a1200d078ef453 to your computer and use it in GitHub Desktop.
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