摘要: import asyncio from threading import Thread import time print('main start:',time.time()) async def download(i): print(i, time.time()) await asyncio.sleep(i) b=linkextractor(i) if b ... 阅读全文
posted @ 2018-12-08 22:09 CrossPython 阅读(182) 评论(0) 推荐(0)
摘要: https://www.jianshu.com/p/0efdc952e8ca 阅读全文
posted @ 2018-12-08 21:22 CrossPython 阅读(833) 评论(0) 推荐(0)
摘要: import asyncio from threading import Thread import time now = lambda: time.time() print('start',now()) def start_loop(loop): asyncio.set_event_loop(loop) loop.run_forever() async def do_so... 阅读全文
posted @ 2018-12-08 17:45 CrossPython 阅读(193) 评论(0) 推荐(0)
摘要: 单个的task 阅读全文
posted @ 2018-12-08 10:55 CrossPython 阅读(226) 评论(0) 推荐(0)
摘要: close的方法主要是关闭子生成器,需要注意的有4点: 1.如果生成器close后,还继续next,会报错StopIteration [图片] 2.如果我捕获了异常,将GeneratorExit处理了,之后还有一个yield,这时候close之后,还要next会报错RuntimeError异常 3. 阅读全文
posted @ 2018-12-08 09:49 CrossPython 阅读(216) 评论(0) 推荐(0)