def start_search_tasks():
"""
Before everything, kill if there is any running search tasks. Then start the search tasks
concurrently.
"""
global SEARCH_TASKS
logging.info("(Re)populated config collections from config file. "
"Cancelling previous loops and restarting them again with the new config.")
for looping_task in SEARCH_TASKS:
logging.info("Cancelling this loop: %r", looping_task)
looping_task.stop()
SEARCH_TASKS = []
searches = CONFIG['Searches'].values()
search_count = len(searches)
logging.info("Search count: %d", search_count)
reactor.suggestThreadPoolSize(search_count)
try:
for search in searches:
search_obj = Search(SERVICE_CLASS_MAPPER.get(search['destination']['service']), search,
CONFIG)
do_search_concurrently(search_obj)
except Exception as exception:
logging.exception("Exception occurred while processing search. %s", exception.message)
评论列表
文章目录