From 6339864f95d4ecaed5e428b342277dce9457d954 Mon Sep 17 00:00:00 2001 From: Julia Medina Date: Thu, 14 Aug 2014 12:32:37 -0300 Subject: [PATCH] Minor refactor in the docs and functions used in the shell command --- scrapy/commands/shell.py | 6 +++++- scrapy/crawler.py | 8 +++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/scrapy/commands/shell.py b/scrapy/commands/shell.py index e4d32c314..e2ef1545e 100644 --- a/scrapy/commands/shell.py +++ b/scrapy/commands/shell.py @@ -50,11 +50,15 @@ class Command(ScrapyCommand): elif url: spidercls = spidercls_for_request(spiders, Request(url), spidercls, log_multiple=True) + + # The crawler is created this way since the Shell manually handles the + # crawling engine, so the set up in the crawl method won't work crawler = self.crawler_process._create_logged_crawler(spidercls) + # The Shell class needs a persistent engine in the crawler crawler.engine = crawler._create_engine() crawler.engine.start() - self.crawler_process._start_logging() + self.crawler_process.start(start_reactor=False) self._start_crawler_thread() shell = Shell(crawler, update_vars=self.update_vars, code=opts.code) diff --git a/scrapy/crawler.py b/scrapy/crawler.py index 52e57fe83..e0524021a 100644 --- a/scrapy/crawler.py +++ b/scrapy/crawler.py @@ -126,13 +126,11 @@ class CrawlerProcess(CrawlerRunner): self._stop_logging() reactor.callFromThread(self._stop_reactor) - def start(self, stop_after_crawl=True): - self._start_logging() - self._start_reactor(stop_after_crawl) - - def _start_logging(self): + def start(self, stop_after_crawl=True, start_reactor=True): self.log_observer = log.start_from_settings(self.settings) log.scrapy_info(self.settings) + if start_reactor: + self._start_reactor(stop_after_crawl) def _start_reactor(self, stop_after_crawl=True): if stop_after_crawl: