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
Shortcut for idle #1051
base: master
Are you sure you want to change the base?
Shortcut for idle #1051
Conversation
LGTM. Only the existence of the idle method A typo can accidentally define it instead of |
Is there something else need to be done besides changing its name? |
It doesn't yet fullfill the requirements of #740, it's nothing more than a signal shortcut so far. As per #740,
|
Hi, I am new here. Do you mean something like this? |
This looks more like it, in theory. But if you reference @dangra, @kmike, could you take a look at this? I'd love to see this make the next release if we can make it work. |
This
I'm also thinking about the API - maybe we can make something even more user-friendly, and leave 'idle' signal for advanced use cases? For example, we may allow start_requests to yield a special value, 'WhenQueueEmpty' or 'WaitUntilIdle' (too much iIlilI though): import scrapy
class MySpider(scrapy.Spider):
def start_requests(self):
# send some seed urls
for url in self.start_urls:
yield scrapy.Request(url, ...)
yield scrapy.WaitUntilIdle
# Scrapy returns the control here when there is no more
# requests in queue - when idle signal fires.
while True:
try:
for url in self.get_batch_from_redis():
yield scrapy.Request(url, ...)
yield WaitUntilIdle
except NoMoreRequests:
break |
Sorry for my disappearance. @kmike for you opinions: what happens if idled returned nothing?If users implement the idled() and return nothing, or something other than a generator, nothing will happen. it should be documented how to stop the spider from idled signal; usage example in docs would be good;I added a there should be more tests, at least for request handling.I add some tests in the test case. But the test failed because the engine of the crawler did not exist. How can I fix this? Another APII am not sure which one is better. I think this should let core developers to decide. |
related to issue #740