目的:多线程请求url, 提高qps
代码分享:
coding=utf-8
import os
import time
import threading
from random import random
from Queue import Queue
import sys, json, requests, datetime
from threading import Thread, Lock
import multiprocessing as mp
import logging
import logging.handlers
class LogLauncher:
@staticmethod
def launch(log_file_path, log_level):
dir_name = os.path.dirname(log_file_path)
if not os.path.exists(dir_name):
os.makedirs(dir_name)
level_dict = {“ERROR”: logging.ERROR, “WARNING”: logging.WARNING, “INFO”: logging.INFO, “DEBUG”: logging.DEBUG}
log_level = log_level.upper()
level_indicator = logging.DEBUG
if level_dict.has_key(log_level):
level_indicator = level_dict[log_level]
log = logging.getLogger(’’)
log.setL