Fix Spider.custom_settings #1276
Conversation
#1128 moved spidercls.update_settings call to a later stage; this commit moves it back.
Makes sense, +1 to merge. I placed wrongly the settings update and freeze in 6f9265b. It should be safe to move the |
@curita I kept
Is it no longer needed? |
Oh, forgot about that comment, I was thinking it's probably better to deal with that once the addons support is implemented. I guess keeping the freeze call where it is is less restrictive now that the change it's already implemented. +1 to merge this pull request as it is then. |
@kmike @curita I want to ask you a question. Why extensions, middlewares and pipelines are initialized during I'm asking this because sometimes I feel like I want to change some crawl settings after spider initialization and initialize middlewares only after that. For example I got request from customer to make it possible to set
that task would be as easy as set CLOSESPIDER_TIMEOUT in |
@dangra please check comment above, maybe you can explain what design decision is behind current initialization order? I forgot to mention you in the comment, and you're obviously the person who knows almost everything about Scrapy. |
@chekunkov |
@nramirezuy |
Also it could happen that spider has some logic to decide whether or not this setting should be set based on spider arguments, |
@chekunkov: I think you have a point, the order of components initialization is not clear but it is better to propose changing it in a new ticket. Scrapy 1.0 is pretty much ready, so we can work on your problem for 1.1. |
Opened a new ticket #1305 |
I noticed that a CloseSpider extension doesn't get activated when CLOSESPIDER_PAGECOUNT option is set in spider's
custom_settings
. Other extensions (AutoThrottle, LogStats, etc) are also not activated.This happens because extensions check settings in
from_crawler
methods, andcrawler.settings
doesn't contain spider settings yet becausespidercls.update_settings
call was moved to a later stage by #1128.