Scrapy 是单线程还是多线程?

编程入门 行业动态 更新时间:2024-10-15 06:15:16
本文介绍了Scrapy 是单线程还是多线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Scrapy 中的并发设置很少,例如 CONCURRENT_REQUESTS.这是否意味着 Scrapy 爬虫是多线程的?因此,如果我运行 scrapy crawl my_crawler 它实际上会并行触发多个并发请求?我问是因为,我读过 Scrapy 是单线程的.

There are few concurrency settings in Scrapy, like CONCURRENT_REQUESTS. Does it mean, that Scrapy crawler is multi-threaded? So if I run scrapy crawl my_crawler it will literally fire multiple simultaneous requests in parallel? Im asking because, I've read that Scrapy is single-threaded.

推荐答案

Scrapy 是单线程的,除了交互式 shell 和一些测试,参见 来源.

Scrapy is single-threaded, except the interactive shell and some tests, see source.

它建立在 Twisted 之上,它也是单线程的,并利用了它有自己的异步并发功能,例如 twisted.internet.interfaces.IReactorThreads.callFromThread,见来源.

It's built on top of Twisted, which is single-threaded too, and makes use of it's own asynchronous concurrency capabilities, such as twisted.internet.interfaces.IReactorThreads.callFromThread, see source.

更多推荐

Scrapy 是单线程还是多线程?

本文发布于:2023-06-01 18:25:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/422858.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多线程   单线程   Scrapy

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!