创建多个线程并启动这些线程 th_num : 15
th_num = conf["crawl_threads"] self._thread_list = [] self._thread_states = [None,] * th_num for tid in range(th_num): th = threading.Thread(target=self.crawl_process, args=(tid,) ) self._thread_list.append(th) th.start()
判断此线程是否存在,若不存在 则新建并启动线程
if self._thread_handle != None: raise ValueError, "Loader has already started" self._thread_handle = threading.Thread(target=self._loop_scan, args=()) self._scan_flag = True self._thread_handle.start()