摘要:
imap imap_unordered 阅读全文
摘要:
每2秒弹出一组3个的 ‘got html text success’ Semaphore底层是用Condition实现的 阅读全文
摘要:
1 #!/user/bin/env python 2 # -*- coding:utf-8 -*- 3 4 # 条件变量,用于复杂的线程间同步 5 # 通过condition完成协同读诗 6 from threading import Lock 7 from threading import Condition 8 import threading 9 10 11 cla... 阅读全文
摘要:
1.用锁会影响性能 2.锁会引起死锁 RLock 阅读全文
摘要:
1.线程通信方式--共享变量 缺点,共享变量需要加锁,来达到我们想要的效果 ps:不要去尝试去运行,我设置了while循环,而且没有设置守护线程。。。 2.通过queue的方式进行线程间的通信 阅读全文
摘要:
1.通过Thread类实例化 2.通过继承Thread来实现多线程 阅读全文
摘要:
1 #!/user/bin/env python 2 # -*- coding:utf-8 -*- 3 4 # gil global interpreter lock(cpython)全局解释器锁 5 # python中一个线程对应于c语言中的一个线程 6 # gil时的同一时刻只有一个线程在一个cpu上执行字节码,无法将多个线程映射到多个cpu上执行 7 # gil会根据执行的... 阅读全文
摘要:
1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 4 # requests -> urllib -> socket 5 import socket 6 from urllib.parse import urlparse 7 8 9 def get_url(url): 10 # 通过socket请求html 11 ... 阅读全文