Python threads stack_size and segfaults

别说谁变了你拦得住时间么 提交于 2019-12-06 11:57:47

Why on earth are you spawning 500 threads? That seems like a terrible idea!

Remove threading completely, use an event loop to do the crawling. Your program will be faster, simpler, and easier to maintain.

Lots of threads waiting for network won't make your program wait faster. Instead, collect all open sockets in a list and run a loop where you check if any of them has data available.

I recommend using Twisted - It is an event-driven networking engine. It is very flexile, secure, scalable and very stable (no segfaults).

You could also take a look at Scrapy - It is a web crawling and screen scraping framework written in Python/Twisted. It is still under heavy development, but maybe you can take some ideas.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!