def testCacheWorks(seconds_if_uncached=50): """ This should not take too long if the cache works. :param seconds_if_uncached: How many seconds this would take without caching. """ install_4plebs_cache() print("Testing if the request cache works.") for i in range(0, seconds_if_uncached): print(requests.get('http://httpbin.org/delay/1'))
#!/usr/bin/env python3 import csv import datetime import os from pprint import pprint from typing import List, Dict import requests from cache import install_4plebs_cache from contentFlagger import ContentFlaggerBadWords, ContentFlaggerTerrorist install_4plebs_cache() TOTALLY_LEGIT_HEADERS = { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/50.0.2661.102 Safari/537.36 ' } ESCAPE_TABLE = { # "&": "&", '"': """, "'": "'", # ">": ">", # "<": "<", ',': ",", '\n': '\\n', }
def testCacheWorks(): """This should not take 50 seconds if the cache works.""" install_4plebs_cache() print("Testing if the request cache works.") for i in range(0, 10): print(requests.get('http://httpbin.org/delay/5'))