在 v2ex 上提问。有人说使用 Gevent 并开启猴子补丁,如果一个线程阻塞也是会影响整个程序线程的。 但我测试 20 个 get 任务时:
但,1000 个任务,使用 多线程明显比多协程快 30% 左右。这是不是因为某个协程的 requests.get 阻塞的整个线程呢? 另问:在做一个线上持续运行的爬虫时,应该如何分配进程、线程、携程才能使带宽、硬件有最佳使用率呢?
条件:python 2.7.8
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
When there are ten thousand concurrent tasks, the advantages of coroutines are reflected~Coroutines are not faster than threads, but in ultra-high concurrency situations, they are more stable than multi-threads and account for Few resources.
When there are ten thousand concurrent tasks, the advantages of coroutines are reflected~
Coroutines are not faster than threads, but in ultra-high concurrency situations, they are more stable than multi-threads and account for Few resources.