mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-27 04:24:05 +00:00
more efficient ExecutionEngine.spider_is_idle
This commit is contained in:
parent
8a391a557f
commit
c6591b5c9f
@ -177,12 +177,23 @@ class ExecutionEngine(object):
|
||||
return d
|
||||
|
||||
def spider_is_idle(self, spider):
|
||||
scraper_idle = self.scraper.slot.is_idle()
|
||||
pending = self.slot.scheduler.has_pending_requests()
|
||||
downloading = bool(self.downloader.active)
|
||||
pending_start_requests = self.slot.start_requests is not None
|
||||
idle = scraper_idle and not (pending or downloading or pending_start_requests)
|
||||
return idle
|
||||
if not self.scraper.slot.is_idle():
|
||||
# scraper is not idle
|
||||
return False
|
||||
|
||||
if self.downloader.active:
|
||||
# downloader has pending requests
|
||||
return False
|
||||
|
||||
if self.slot.start_requests is not None:
|
||||
# not all start requests are handled
|
||||
return False
|
||||
|
||||
if self.slot.scheduler.has_pending_requests():
|
||||
# scheduler has pending requests
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
@property
|
||||
def open_spiders(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user