Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate or remove KEEP_ALIVE, document how to tell the shell apart #5837

Open
Gallaecio opened this issue Feb 27, 2023 · 2 comments
Open

Comments

@Gallaecio
Copy link
Member

Looking for a way to distinguish when code is executed within scrapy shell or otherwise, I found that scrapy shell sets this setting to True.

This setting was added in Scrapy 0.10, and removed in the follow-up Scrapy 0.14, but it seems we missed the appearance I linked above.

I wonder if anyone out there is using this setting for the purpose I was looking for, to tell apart scrapy shell from something else. And I wonder if, rather than removing that line of code, we should go for a more complex deprecation procedure.

But if we are removing or deprecating what to me looks like the most straightforward way at the moment to tell if you are in scrapy shell, I think we may want to consider providing or documenting an alternative way as part of the change that removes or deprecates this setting.

For example, we could add a new setting (e.g. IN_SHELL=True). Or maybe it is possible to check if the current thread is the main one, and detect it that way. But I think we should choose what the right way to check this should be, and cover it in the documentation.

@Gallaecio
Copy link
Member Author

@VMRuiz found that crawler.engine.slot evaluated to falsy from scrapy shell.

@VMRuiz
Copy link
Contributor

VMRuiz commented Feb 27, 2023

Yes, but it's probably something unrelated due to how crawler is instantiated during the Shell creation and I wouldn't use crawler.engine.slot is None to determine if you are in scrapy shell or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants