1 import time
 2 from concurrent.futures import ThreadPoolExecutor
 3 
 4 def RunBenchmark(url):
 5     print('GET %s' % url)
 6     response = url
 7     time.sleep(3)
 8     return(url+" FINISHED")
 9 
10 def RunPool():
11     urls = 'CPU'
12     pool = ThreadPoolExecutor(1)          #启动一个线程池
13     task=pool.submit(RunBenchmark, urls)     #在另外的线程中运行RunBenchmark() 
14     while(not task.done()):             #task.done()表示线程池中的工作完成了
15         print("ooo")                 #主线程中可以执行其他工作
16         time.sleep(0.5)
17     print("bye")
18 
19 if __name__ == '__main__':
20     RunPool()

 

 https://www.jianshu.com/p/b9b3d66aa0be

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

https://blog.csdn.net/sinat_34461756/article/details/83866300

https://cloud.tencent.com/developer/article/1187407

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄