scrapy中engine.py的源码分析如下:
"""
engine.py提供了2个类:Slot和ExecutionEngine
Slot: 提供了几个方法添加请求,删除请求,关闭自己,触发关闭方法
它使用Twisted的主循环reactor来不断的调度执行Engine的"_next_request"方法,这个方法也是核心循环方法。
ExecutionEngine: 引擎的执行任务
爬虫引擎是控制调度器,下载器和爬虫的。
This is the Scrapy engine which controls the Scheduler, Downloader and Spiders.
For more information see docs/topics/architecture.rst
"""
import logging
from time import time
# Twisted是用Python实现的基于事件驱动的网络引擎框架,这里引用了它,可能用于网络方面
from twisted