def run_thread(req_list, name=None, is_lock=True, limit_num=8):
'''
?????
- req_list ????, list, ?????????, ???
- [
- (func_0, (para_0_1, para_0_2, *,)),
- (func_1, (para_1_1, para_1_2, *,)),
- *
- ]
- name ???, str, ???None
- is_lock ??????, bool, ???True, ????, False????
- limit_num ?????, int, ???8
'''
queue = deque(req_list)
while len(queue):
if threading.active_count() <= limit_num:
para = queue.popleft()
now_thread = threading.Thread(
target=para[0], args=para[1], name=name, daemon=True)
now_thread.start()
if is_lock:
for now_thread in threading.enumerate():
if now_thread is not threading.currentThread():
now_thread.join()
评论列表
文章目录