Commit 54471006 authored by wang's avatar wang

1

parent 1a4197c8
...@@ -77,28 +77,27 @@ def exec(thread_id): ...@@ -77,28 +77,27 @@ def exec(thread_id):
def run(): def run():
brush_thread = 2 brush_thread = 2
while True:
print(f'本次并发数 {brush_thread}') print(f'本次并发数 {brush_thread}')
# pool = ThreadPoolExecutor(max_workers=brush_thread) # pool = ThreadPoolExecutor(max_workers=brush_thread)
# all_task = [pool.submit(exec, (i)) for i in range(brush_group)] # all_task = [pool.submit(exec, (i)) for i in range(brush_group)]
# brush_check = CONFIG['internal']['reverse']['making']['brush_check'] # brush_check = CONFIG['internal']['reverse']['making']['brush_check']
# wait(all_task, return_when=ALL_COMPLETED) # wait(all_task, return_when=ALL_COMPLETED)
# print(f'休息 {brush_check} 秒') # print(f'休息 {brush_check} 秒')
# time.sleep(brush_check) # time.sleep(brush_check)
with ThreadPoolExecutor(max_workers=brush_thread) as executor: with ThreadPoolExecutor(max_workers=brush_thread) as executor:
objs = [] objs = []
for t in range(1, brush_thread + 1): for t in range(1, brush_thread + 1):
task = executor.submit(exec, t) task = executor.submit(exec, t)
objs.append(task) objs.append(task)
while 1: while 1:
time.sleep(1) time.sleep(1)
for n, o in enumerate(objs): for n, o in enumerate(objs):
if o.done(): if o.done():
task = executor.submit(exec, n + 1) task = executor.submit(exec, n + 1)
objs[n] = task objs[n] = task
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment