import argparse
class RequestThread(threading.Thread):
def __init__(self,input_file,debug_level):
threading.Thread.__init__(self)
self.input_file = input_file
self.debug_level = debug_level
def run(self):
request(self.input_file, self.debug_level)
def run(args):
thread_pool = []
for thread_id in range(args.thread_num):
thread = RequestThread(args.input,args.debug_level)
thread_pool.append(thread)
thread.start()
for thread in thread_pool:
thread.join()
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-n","--thread_num",nargs='?', const=1, type=int, default=1,help="thread num")
parser.add_argument("-d","--debug_level",nargs='?', const=1, type=int, default=1,help="debug level")
parser.add_argument("-i","--input",help="input file,format city_id\\tquery")
args = parser.parse_args()
run(args)