-
Notifications
You must be signed in to change notification settings - Fork 20
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
Fail on SPM + transparent mode #152
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #152 +/- ##
==========================================
+ Coverage 98.89% 98.94% +0.04%
==========================================
Files 10 10
Lines 724 756 +32
==========================================
+ Hits 716 748 +32
Misses 8 8
|
scrapy_zyte_api/handler.py
Outdated
@@ -62,6 +62,29 @@ def __init__( | |||
raise NotConfigured( | |||
"Zyte API is disabled. Set ZYTE_API_ENABLED to True to enable it." | |||
) | |||
if settings.getbool("ZYTE_API_TRANSPARENT_MODE", False) and ( | |||
settings.getbool("ZYTE_SMARTPROXY_ENABLED", False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible to disable SPM using spider attributes; how do we handle this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we move this to a signal handler for spider_opened
, where we can check the spider as well, and close the spider from there in this scenario?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I think there is also a middleware method (is_enabled?) which can be useful, but I haven't really checked it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with raising
NotConfigured
from the handlers.However, I wonder if instead we should treat this as a fatal error and close the spider with a custom reason.
In fact, I wonder if we should do that for other
NotConfigured
errors in the handler, since some users have a hard time figuring out those kind of issues from the logs, and a non-working HTTP/HTTPS handler feels like a critical-enough issue to warrant closing the spider until it is addressed.