def worker(): while True: address = queue.get() utils.check_website(address) # For each address popped, mark it as processed queue.task_done()
def worker(): # Constantly check the queue for addresses while True: address = task_queue.get() check_website(address) task_queue.task_done()
def main(): start_time = time.time() for address in WEBSITE_LIST: check_website(address) end_time = time.time() print("Time for SerialSquirrel: %ssecs" % (end_time - start_time))
# serial_squirrel.py from websites import WEBSITE_LIST from utils import check_website import time start_time = time.time() for address in WEBSITE_LIST: check_website(address) end_time = time.time() print("Time for SerialSquirrel: %ssecs" % (end_time - start_time)) # WARNING:root:Timeout expired for # website http://really-cool-available-domain.com # WARNING:root:Timeout expired for # website http://another-really-interesting-domain.co # WARNING:root:Website http://bing.com returned status_code=405 # Time for SerialSquirrel: 15.881232261657715secs
import time import utils start_time = time.time() for address in utils.WEBSITE_LIST: utils.check_website(address) end_time = time.time() print("Time in Serial %s sec" %(end_time - start_time))
def worker(): while True: address = task_queue.get() check_website(address) task_queue.task_done()
def check_website_task(website): return check_website(website)
def test_invalid_site(): site = 'feadasf.fasdf.com.au' (response, err), duration = utils.check_website(site) assert response is None assert type(duration) == float
def test_valid_site(): site = 'https://aiven.io' (response, err), duration = utils.check_website(site) assert response.status_code == 200 assert type(duration) == float