2019年10月7日

进程池线程池小练习.py

摘要: from concurrent.futures import ThreadPoolExecutor import requests, time def get(url): print('GET %s'%url) resposn = requests.get(url) time.sleep(3) return {'url':url, 'content':resposn.text} def parse 阅读全文

posted @ 2019-10-07 20:48 别离 阅读(178) 评论(0) 推荐(0) 编辑

异步调用与回调机制

摘要: # 提交任务的俩方式 #1,同步调用:提交完任务,在原地等待任务执行完毕,拿到结果,再执行下一段代码,导致程序串行执行 import time, random from concurrent.futures import ThreadPoolExecutor def la(name): print('%s 在拉屎!'%name) time.sleep(random.randi... 阅读全文

posted @ 2019-10-07 19:28 别离 阅读(362) 评论(0) 推荐(0) 编辑

导航